×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

I have an Access database, I want t

I have an Access database, I want t

I have an Access database, I want t

(OP)
I have an Access database, I want to check a field in a table to see if it is null. If it is null I want to run a line of code:

Do.Cmd.OpenQuery “QueryTitle”, acViewNormal

If no null value is found I want to close the if statement and then run a different line of code:

Do.Cmd.OpenTable “TableName”, acViewNormal, acEdit

This seems that it should be simple but I am having problems.

Any assistance is appreciated.

This is what I have tried:

If
Table.Field Is Null
Then
DoCmd.OpenQuery "Insert into SubTable", acViewNormal
Else
End If
'DoCmd.OpenTable "Table", acViewNormal, acEdit

RE: I have an Access database, I want t

lameid and I are guessing here because you are not very clear of what you need.
"check a field in a table to see if it is null" - so you have a table with several fields and you want to know if particular field has NULL in all records in this table?

Something like:
tblMyTable
ID  LastName   Age  Gender
1     Brown   NULL   M
2     White   NULL   F
3     Green   NULL   F
4     Yellow  NULL   X 

Or, you have a record/some records that you want to check if one of the fields in a record is NULL?


---- Andy

There is a great need for a sarcasm font.

RE: I have an Access database, I want t

(OP)
Andrzejek

Yes, I want to check a single field in a table to determine if any of the records are null. If so I want to run a query, if not I want to run a different query.

Ron--

RE: I have an Access database, I want t

How about:

If DCount("UnitPrice", "Order Details", "OrderID IS NULL") = 0 Then
    'No NULLs in OrderID field
    'DoCmd.OpenTable "Table", acViewNormal, acEdit
Else
    'There is/are NULLs in OrderID field
    DoCmd.OpenQuery "Insert into SubTable", acViewNormal
End If
 
Of course, use your own field/table


---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close