Error with Docmd.runSQL

B

Boon

Hi,

I would like to know what is the best way to handle this problem.

I use Docmd.runSQL .........INSERT in to the table.

Now in the SQL commannd I have a variable in it. That variable reads the
text from the textbox in the form. Now, when the textbox left blank, the
variable is null, and the SQLcommand is error.

What is the best way of preventing this? My idea is to use IF
isnull(variable) THEN variable=0.

thanks.
 
J

John W. Vinson

Hi,

I would like to know what is the best way to handle this problem.

I use Docmd.runSQL .........INSERT in to the table.

Now in the SQL commannd I have a variable in it. That variable reads the
text from the textbox in the form. Now, when the textbox left blank, the
variable is null, and the SQLcommand is error.

What is the best way of preventing this? My idea is to use IF
isnull(variable) THEN variable=0.

thanks.

Please post your code and the SQL statement. We can't see it from here. My
guess is that you can use the NZ() function to turn your variable into a zero
but it's hard to be sure!
 
D

Douglas J. Steele

You could use the Nz function in your code.

If you can't figure it out, post your actual code.
 

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

Top