Error with Docmd.runSQL

  • Thread starter Thread starter Boon
  • Start date Start date
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.
 
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!
 
You could use the Nz function in your code.

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