I'm getting crazy!

R

Renato

Hi there,
I'm working on a Access2000 form ; the form is used to fill
data in a linked SQL Server table ; I've two problems :
1. Textbox : I'm trying to check the value entered by the user
in a textbox using a simple if cycle as follow:
...
if mytextbox.value is null then msgbox("error")
...
It happens that if the value is null the if condition
doesn't work and my msgbox doesn't appear ;
I'm sure it is null because I add an expression control to watch this control.
It also doesn't work if I exchange in the condition the 'null' with "" or 0.
The only way I've seen it works is to check the property text, but in that
case I need the control to be active before, but this is a bad solution as
my form every time I use the setfocus method jump from a control to another...
What's the problem?
2. I'm trying to trap errors coming from my MSDE server when the user does not
respect the validation rule of a certain field : I'm able to see the error and the
description trapping the ODBC error but the description is full of data; I just
need to have for example the name of the field where the data is not correct ;
so , how can read the native SQL Server error code & description from
the form code?
Thank you in advance,
Renato
 
S

Sandra Daigle

Hi Renato,

Any comparison to Null results in Null. Since Null is not true, any
comparison to Null in an If-Then clause will branch around the code for the
true condition. When checking a control or variable for the null value you
must use the IsNull function.

If isnull(me.Textbox) then
msgbox "Error"
Endif

I don't have an answer for you on the second part of your question. What
errors are you seeing? Is there a pattern in the description that would
allow you to parse out the field name?
 

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

getting type mismatch 3
Confused about setfocus 2
Using If & And 0
Processing long text 2
If one thing and another thing 4
If else subform reference access 2007 2
Filtering a form - wait 2
Checking Date for Null 14

Top