isnull(txtName) not working.

G

Guest

Hi!
I have a SQLServer backend connected to Access 2000 forms via DAO. I have 2
forms. In the first one, I enter First name and click the "Search" button. It
opens another form which has a query for its control source that looks for
all names like the one entered. If there is no name in the db, I do not want
this form to open. Hence on the "Open Event" of the second form I coded " if
isnull(txtFname) then docmd.close" but it does not seem to work. The form
opens blank anyway. Is this because of the DAO type of connection to tables?
What could be the problem and how should I solve it?
Please help! TIA.
Shree
 
B

Brendan Reynolds

The Open event may be too soon to check the value of a bound control, try
the Load event instead. Also, it may be possible for the control to contain
an empty string instead of a Null value. Try the following expression, which
will return True when the control contains either a Null value or an empty
string ...

If Len(txtFname & vbNullString) = 0 Then
 
G

Guest

Thanks for your reply. I tried your code. Now I am gettinga msg saying " you
have entered an expression that has no value." What does that mean?
Shree
 

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