Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have an Access database, I want t

Status
Not open for further replies.

ronwmon

Programmer
Jul 13, 2007
97
US
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
 
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:
[pre]
tblMyTable
ID LastName Age Gender
1 Brown NULL M
2 White NULL F
3 Green NULL F
4 Yellow NULL X[/pre]

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.
 
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--
 
How about:

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


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top