Keith
Registered User.
- Local time
- Today, 03:33
- Joined
- May 21, 2000
- Messages
- 129
I am running the following code from a command button on a form. I am trying to write a number of records to a table dependent on the value of a text box (txtQuantityVeh) on the form. my code is:
Dim SVE As String, number As Long
For number = 1 To Me.txtQuantityVeh.Value
SVE = "Insert into tblMovement(HireId,VehNo,)" & " Values ( ' " & [txtHireId].Value & " ' & ' " & number & " ' )"
Debug.Print (SVE)
DoCmd.SetWarnings False
DoCmd.RunSQL (SVE)
number = number + 1
Next number
DoCmd.SetWarnings True
I get an error 'Syntax Error in INSERT INTO STATEMENT'
The immediate window shows SVE as:
Insert into tblMovement(HireId,VehNo,) Values ( ' 82 ' & ' 1 ' )
I get the same error whatever value txtQuantity is. I would appreciate any guidance as to what I am doing wrong
Dim SVE As String, number As Long
For number = 1 To Me.txtQuantityVeh.Value
SVE = "Insert into tblMovement(HireId,VehNo,)" & " Values ( ' " & [txtHireId].Value & " ' & ' " & number & " ' )"
Debug.Print (SVE)
DoCmd.SetWarnings False
DoCmd.RunSQL (SVE)
number = number + 1
Next number
DoCmd.SetWarnings True
I get an error 'Syntax Error in INSERT INTO STATEMENT'
The immediate window shows SVE as:
Insert into tblMovement(HireId,VehNo,) Values ( ' 82 ' & ' 1 ' )
I get the same error whatever value txtQuantity is. I would appreciate any guidance as to what I am doing wrong