Need guidance on query - sytax error in Insert Into

  • Thread starter Thread starter Alp Bekisoglu
  • Start date Start date
A

Alp Bekisoglu

Hi Experts,

Just can't seem to locate where the error is. Bit details; A2K, trying to
use an append query on a table via an unbound form through VBA.

Table consists of: kat_id (autonum, PK), kat_co_id(num), kat_fair_id(num),
kat_tarih(date),
kat_kapali_shell_m2(num), kat_kapali_booth_m2(num), kat_acik_m2(num),
kat_shell_fiyat(num,single), kat_booth_fiyat(num,single),
kat_space_fiyat(num,single), kat_shell_kdv(num,single),
kat_booth_kdv(num,single), kat_space_kdv(num,single), kat_shell_hall(txt),
kat_shell_lokasyon(txt), kat_booth_hall(txt), kat_booth_lokasyon(txt),
kat_space_hall(txt), kat_space_lokasyon(txt).

The code is:
strSQL = "INSERT INTO katilim ( kat_co_id, kat_fair_id, kat_tarih,
kat_kapali_shell_m2, kat_kapali_booth_m2, kat_acik_m2, kat_shell_fiyat,
kat_booth_fiyat, kat_space_fiyat, kat_shell_kdv, kat_booth_kdv,
kat_space_kdv, kat_shell_hall, kat_shell_lokasyon, kat_booth_hall,
kat_booth_lokasyon, kat_space_hall, kat_space_lokasyon )"
strSQL = strSQL & " VALUES (" & Me.firma_no & ", " & _
Me.fairname & ", " & _
Me.tarih & ", " & _
Me.shellamt & ", " & _
Me.boothamt & ", " & _
Me.spaceamt & ", " & _
Me.shellprc & ", " & _
Me.boothprc & ", " & _
Me.spaceprc & ", " & _
Me.kdvshell & ", " & _
Me.kdvbooth & ", " & _
Me.kdvspace & ", '" & _
Me.holsecim_shell & "', '" & _
Me.koordinat_shell & "', '" & _
Me.holsecim_booth & "', '" & _
Me.koordinat_booth & "', '" & _
Me.holsecim_space & "', '" & _
Me.koordinat_space & "');"

DoCmd.RunSQL strSQL

Thanks in advance,

Alp
 
Don't know why you aren't using a bound form for this, but that is your choice.

Date Fields require # signs as delimiters. So at least these lines need to be revised

Me.fairname & ", " & _
Me.tarih & ", " & _

Table consists of: kat_id (autonum, PK), kat_co_id(num), kat_fair_id(num),
kat_tarih(date),
kat_kapali_shell_m2(num), kat_kapali_booth_m2(num), kat_acik_m2(num),
kat_shell_fiyat(num,single), kat_booth_fiyat(num,single),
kat_space_fiyat(num,single), kat_shell_kdv(num,single),
kat_booth_kdv(num,single), kat_space_kdv(num,single), kat_shell_hall(txt),
kat_shell_lokasyon(txt), kat_booth_hall(txt), kat_booth_lokasyon(txt),
kat_space_hall(txt), kat_space_lokasyon(txt).

The code is:
strSQL = "INSERT INTO katilim ( kat_co_id, kat_fair_id, kat_tarih,
kat_kapali_shell_m2, kat_kapali_booth_m2, kat_acik_m2, kat_shell_fiyat,
kat_booth_fiyat, kat_space_fiyat, kat_shell_kdv, kat_booth_kdv,
kat_space_kdv, kat_shell_hall, kat_shell_lokasyon, kat_booth_hall,
kat_booth_lokasyon, kat_space_hall, kat_space_lokasyon )"
strSQL = strSQL & " VALUES (" & Me.firma_no & ", " & _
Me.fairname & ", #" & _
Me.tarih & "#, " & _
Me.shellamt & ", " & _
Me.boothamt & ", " & _
Me.spaceamt & ", " & _
Me.shellprc & ", " & _
Me.boothprc & ", " & _
Me.spaceprc & ", " & _
Me.kdvshell & ", " & _
Me.kdvbooth & ", " & _
Me.kdvspace & ", '" & _
Me.holsecim_shell & "', '" & _
Me.koordinat_shell & "', '" & _
Me.holsecim_booth & "', '" & _
Me.koordinat_booth & "', '" & _
Me.holsecim_space & "', '" & _
Me.koordinat_space & "');"

DoCmd.RunSQL strSQL
 
Thanks John,

I'll check the one "tarih" (date in Turkish). Didn't think VBA would require
it since sql from a query did not have them. The other, fairname, eventhough
feels like a text field the returned value is numeric.
 
Back
Top