Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error

Status
Not open for further replies.

Sillygirl

Programmer
May 3, 2002
80
US
Can you find the syntax error here??

Dim externdb As Database 'this is the odtagdb database
Dim sql As String
Dim Rows As Integer
Dim today As Variant

today = Now
'update odtagdb

If Not opt = "0" Then
Set externdb = OpenDatabase("", False, False, "ODBC;DSN=ODTAGSQL;DB=tagging")

If Not opt = "4" Then

sql = "Insert into super_change (Location, supervisor, opt, part_Code, id, time_stamp)"
sql = sql + "values ('" + pc + "', "
sql = sql + "'" + super + "', "
sql = sql + "'" + opt + "', "
sql = sql + "'" + Partc + "', "
sql = sql + "' ', "
sql = sql + "'" + Format(Now, "General Date") + "')"

' , VBDA_SQLPASSTHROUGH
Rows = externdb.Execute sql <--- blowinup here
 
Try using # around the date variable instead of '

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
Thats not the line that is blowing up. THe line that is blowing up is:

Rows = externdb.Execute sql
 
The if the table column is formated for a date variable(#) and you are trying to insert a text variable(') the Execute() command will blow up.

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
It looks like your 5th column is an integer (guessing by the name of the field ID). You sql string is trying to insert a space in for this character.

Code:
          sql = "Insert into super_change (Location, supervisor, opt, part_Code, id, time_stamp)"
          sql = sql + "values ('" + pc + "', "
          sql = sql + "'" + super + "', "
          sql = sql + "'" + opt + "', "
          sql = sql + "'" + Partc + "', "
          sql = sql + "NULL, "
          sql = sql + "'" + Format(Now, "General Date") + "')"

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
The concatenation operator in VB is & not +

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top