 |
 |

03-08-2004, 01:01 PM
|
|
Centurion
|
|
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
|
|
Passing Variables to SQL
|
I am trying to pass the name of a table to my access query but get an error (Run-time error '-2147217900(80040e14)': Syntax error in query. Incomplete clause.
Here is the code I am using:
If Month(Date) = "3" Then Mnth = "Mar"
ElseIf Month(Date) = "6" Then
Mnth = "Jun"
ElseIf Month(Date) = "9" Then
Mnth = "Sep"
ElseIf Month(Date) = "12" Then
Mnth = "Dec"
ElseIf Month(Date) = "1" Then
Mnth = "Jan"
ElseIf Month(Date) = "2" Then
Mnth = "Feb"
ElseIf Month(Date) = "4" Then
Mnth = "Apr"
ElseIf Month(Date) = "5" Then
Mnth = "May"
ElseIf Month(Date) = "7" Then
Mnth = "Jul"
ElseIf Month(Date) = "8" Then
Mnth = "Aug"
ElseIf Month(Date) = "10" Then
Mnth = "Oct"
ElseIf Month(Date) = "11" Then
Mnth = "Nov"
Else
End If
Today = CStr(Mnth & Dizay)
Set add = ACD.Execute("Select Product, action, status from '" & Today & "'")
Any ideas on why this error is thrown? Any help would be much appreciated!
MJ
|
Last edited by Mjawors; 03-08-2004 at 01:15 PM.
|

03-08-2004, 02:44 PM
|
|
Steppe Walker
Retired Moderator * Expert *
|
|
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
|
|
Hi,
Code:
Set add = ACD.Execute("Select Product, [action], [status] From " & Today & "")
Regards,
Shurik.
|
__________________
"A diaper is not like a computer that makes satisfying burbling noises from time to time, hinting at great inner complexity." Malcolm Gladwell
"I'm sitting here completely surrounded by no beer." Onslow, 'Keeping up appearances'
|

03-09-2004, 06:01 AM
|
|
Centurion
|
|
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
|
|
|
Perfect! Thanks, for the help with that... Why is it necessary to add the [] around the other two columns in the SQL query?
|
|

03-09-2004, 06:10 AM
|
|
Steppe Walker
Retired Moderator * Expert *
|
|
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
|
|
|
The brackets are needed in case of so called reserved words in Visual Basic, in this case Status and Action are 'properties'.
Better yet avoid giving such names at all.
Regards,
Shurik
|
__________________
"A diaper is not like a computer that makes satisfying burbling noises from time to time, hinting at great inner complexity." Malcolm Gladwell
"I'm sitting here completely surrounded by no beer." Onslow, 'Keeping up appearances'
|

03-09-2004, 06:47 AM
|
|
Centurion
|
|
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
|
|
Quote:
|
Originally Posted by Shurik12
The brackets are needed in case of so called reserved words in Visual Basic, in this case Status and Action are 'properties'.
Better yet avoid giving such names at all.
Regards,
Shurik
|
Unfortunately I am piggybacking off of a DB that is made by another application. Thanks again for the help.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|