SQL Problem

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 & "')"
 
J

J. Goddard

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
 
D

DS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL UPDATE Problem 1
Adding a record to an Access db using DataAdapter.Update 1
SQL and Null 10
For Loop 6
Check ALL fields for null 2
INSERT Syntax Problem 2
Loop and Insert Problem 5
SQL Synatx Incorrect 6

Top