SQL Problem

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have this statement that is puzzling me. I'm inserting into a Table,
the fields are Text Fields, the values are coming from an unbound textbox.

Normally I would do it like this...

CurrentDb.Execute "INSERT INTO
Customers(CustomerID,BusinessName,FName,LName) " & _
"VALUES(" & Forms!AddCustomer!TxtCustomerID & "," &
Forms!AddCustomer!TxtBusinessName & ", " & _
"" & Forms!AddCustomer!TxtFName & "," & Forms!AddCustomer!TxtLName & ")"

But now I am being forced to add ' around the fields...
Anyone know why?
Thanks
DS

CurrentDb.Execute "INSERT INTO
Customers(CustomerID,BusinessName,FName,LName) " & _
"VALUES(" & Forms!AddCustomer!TxtCustomerID & ",'" &
Forms!AddCustomer!TxtBusinessName & "', " & _
"'" & Forms!AddCustomer!TxtFName & "','" & Forms!AddCustomer!TxtLName & "')"
 
As far as I know, that's the required syntax for SQL and text fields -
for numerics, you don't need the single quotes if they're going into
numeric fields ( in fact putting quotes in generates an error).

John
 
J. Goddard said:
As far as I know, that's the required syntax for SQL and text fields -
for numerics, you don't need the single quotes if they're going into
numeric fields ( in fact putting quotes in generates an error).

John
Thanks John....Perhaps it's time to call it a day! 14 hrs is enough!
DS
 
Back
Top