Question : HELP, I fallen on a 'Runtime Error 3134 Syntax error in INSERT INTO statement' and i can't get up!

i've got this code...

>>>>>
Private Sub cmdAddRecord_Click()
    'Declare strSQL
    Dim strSQL As String
   
   
    'Define SQL
    strSQL = "INSERT INTO pat_substance (patient_id, substance_id, substance_type, route, substance_cd, amount, amount_units, frequency_cd, start_date, note, end_date) values ( '" & Me.intPatientID & "' ," & Me.intSubstanceID & ", '" & Me.txtSubstanceType & "' , '" & Me.txtRoute & "','" & Me.cmbSubstance.Column(0) & "'," & Me.intAlcoholAmount & ", '" & Me.cmbAlcoholUnits.Column(0) & "','" & Me.cmbAlcoholFrequency.Column(0) & "',#" & Me.dtmStartDate & "#, '" & Trim(txtNote) & "', #" & Me.dtmEndDate & "# )"
   
    'Add new record to pat_substance from unbound controls
    DoCmd.RunSQL (strSQL)
   
    'Update query since a record has been added to table
    'Form_frmAlcohol2D.Requery
   
End Sub
>>>>>

i get the error -- "runtime error 3134 Syntax error in INSERT INTO statement" when i click the button

with only 8 fields it works fine, but with 9 it gives me an error

it seems that the SQL value can only be a certain length, because the value is getting cut off at 253 characters
here's an example of that

"INSERT INTO pat_substance (patient_id, substance_id, substance_type, route, substance_cd, amount, amount_units, frequency_cd, start_date, note, end_date) values ( 'T2047' ,750, 'ALCOHOL' , ' ','MOO',77, 'Fifths','2',#12/12/2012#, 'HOW LONG WILL THIS O"

any ideas?

thanks,
Matt

Answer : HELP, I fallen on a 'Runtime Error 3134 Syntax error in INSERT INTO statement' and i can't get up!

I was able to get this to work by changing the field sizes.  Changed note to newnote.
Random Solutions  
 
programming4us programming4us