Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Passing Variables to SQL


Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2004, 01:01 PM
Mjawors Mjawors is offline
Centurion
 
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
Default 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.
Reply With Quote
  #2  
Old 03-08-2004, 02:44 PM
Shurik12 Shurik12 is offline
Steppe Walker

Retired Moderator
* Expert *
 
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
Default

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'
Reply With Quote
  #3  
Old 03-09-2004, 06:01 AM
Mjawors Mjawors is offline
Centurion
 
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
Default

Perfect! Thanks, for the help with that... Why is it necessary to add the [] around the other two columns in the SQL query?
Reply With Quote
  #4  
Old 03-09-2004, 06:10 AM
Shurik12 Shurik12 is offline
Steppe Walker

Retired Moderator
* Expert *
 
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
Default

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'
Reply With Quote
  #5  
Old 03-09-2004, 06:47 AM
Mjawors Mjawors is offline
Centurion
 
Join Date: Jan 2004
Location: Chicago, IL USA
Posts: 150
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables and controls using WinForms and VB.NET Bucky Tutors' Corner 0 02-24-2004 03:45 PM
SQL query pinkcat Database and Reporting 25 02-09-2004 09:36 AM
Passing Non-Global Variables Epo General 3 11-08-2003 08:16 PM
pivot table from access to excel davers55 Word, PowerPoint, Outlook, and Other Office Products 5 10-30-2003 08:50 AM
Passing of variables between 2 forms VBAvid General 9 03-01-2002 06:08 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->