VB script question

Anything and everything software related that doesn't fit above can go in here!
Post Reply
User avatar
bubba
Staff Writer
Staff Writer
Posts: 4765
Joined: Sun May 01, 2005 10:24 am
Location: STL

VB script question

Post by bubba »

ok, a guy on another forum I go to for rc cars had a question on vb script.
I know I know... work related... bleh...

anyways... I am trying to set up a database that exports reports to a network folder.
the problem is people have the network drive different (really anything from q-v that i've seen).

so I set a table in access as a-z. have them choose this value and set it as a string (strdrvltr)

then I try to send it out w/

DoCmd.OutputTo acOutputTable, "22+ Red Tab", acFormatXLS, strdrvltr & ":\engquasn\patterson\inspection inventory\data\22+.xls", False

but it says it cannot output to that location...

anyone have any ideas? I figure there has to be a programmer somewhere in here
well, I suggested he declare and set variables before the output line but he said that he tried that and it still does not allow him to output the file.

but when does it like this
DoCmd.OutputTo acOutputTable, "22+ Red Tab", acFormatXLS, "t:\engquasn\patterson\inspection inventory\data\22+.xls", False
it works just fine.

any ideas
User avatar
pointreyes
Legit Fanatic
Legit Fanatic
Posts: 230
Joined: Wed Nov 23, 2005 2:26 pm

Post by pointreyes »

This is actually a VBA (Visual Basic for Applications) question instead of VB script.

The first example probably does not work because the drive designation needs a quote at the beginning. In other words stating <variable> & ":\...." will render t:\...". I believe when I used to deal with this issue in VBA syntax that I had to use a character reference for the quote and then the variable. e.g. something like chr(34) & <variable> & ":\..." might render "t:\..."
Diagram of Hardware Profile
----------------------------------------------------------
BSD Daemon Copyright 1988 by Marshall Kirk McKusick. All Rights Reserved.
User avatar
Topher
Legit Extremist
Legit Extremist
Posts: 301
Joined: Sun May 01, 2005 11:29 am
Location: Temple of the Rat
Contact:

Post by Topher »

Try This:
DoCmd.OutputTo acOutputTable, "22+ Red Tab", acFormatXLS, Chr(34) & strdrvltr & ":\engquasn\patterson\inspection inventory\data\22+.xls" & Chr(34), False
it's basically the same thing as what pointreyes posted, only with a closing & Chr(34) behind the string.

The problem with this is the space in the path, if it weren't for that, he probably wouldn't be having any problem.

Chr(34) represents a Double Quote ".

Specifying both the Chr(34) and the double quote in the command first wraps your string path in quotes to represent that it's a string, then by placing the Chr(34) on both ends of that ensures that the final concatenated string is passed to the destination with it's quotes around it to keep the path from being looked at as if it was two parameters (because of the space in the path).
Last edited by Topher on Thu May 04, 2006 3:49 pm, edited 1 time in total.
User avatar
bubba
Staff Writer
Staff Writer
Posts: 4765
Joined: Sun May 01, 2005 10:24 am
Location: STL

Post by bubba »

I'll tell him about both ways

Thanks guys
Post Reply