SQL Too Few Parameters

D

DS

I have this SQL code that isn't working, it says too few parameters -1
I'm only putting one field into the tale Customers, the field is PName.
The value from an unbound textbox. If I go to the table and type a new
Pname in it works fine. Is this a Syntax problem?

CurrentDb.Execute "INSERT Into Customers(PName) VALUES(" & Me.Text1 & ")"

Thanks
DS
 
R

Rick Brandt

DS said:
I have this SQL code that isn't working, it says too few parameters -1
I'm only putting one field into the tale Customers, the field is
PName. The value from an unbound textbox. If I go to the table and
type a new Pname in it works fine. Is this a Syntax problem?

CurrentDb.Execute "INSERT Into Customers(PName) VALUES(" & Me.Text1 &
")"

Thanks
DS

Are you sure Me.Text1 doesn't contain a Null value? If it did then the
string would evaluate to...

INSERT Into Customers(PName) VALUES()
 
D

Douglas J Steele

Presumably PName is a text field. That means the value you're writing to it
must have quotes around it:

CurrentDb.Execute "INSERT Into Customers(PName) VALUES(" & Chr$(34) &
Me.Text1 & Chr$(34) & ")"

(Chr$(34) is the equivalent of ".)
 
D

DS

Douglas said:
Presumably PName is a text field. That means the value you're writing to it
must have quotes around it:

CurrentDb.Execute "INSERT Into Customers(PName) VALUES(" & Chr$(34) &
Me.Text1 & Chr$(34) & ")"

(Chr$(34) is the equivalent of ".)
Thanks, Got it to work!
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


Top