Page 1 of 1

VB script question

Posted: Thu May 04, 2006 1:44 pm
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

Posted: Thu May 04, 2006 2:18 pm
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:\..."

Posted: Thu May 04, 2006 3:44 pm
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).

Posted: Thu May 04, 2006 4:14 pm
by bubba
I'll tell him about both ways

Thanks guys