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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a value to null text boxes on a form

Status
Not open for further replies.

luccas

Technical User
Dec 21, 2000
30
0
0
US
I have a form that I am using to run a query. The query name “qryUCQuery” the form name is “frmSelection” it has 2 text boxes on it ,Text0 and Text2. I am using “frmSelection” to specify the values for “qryUCQuery”. The criteria for the query is “Like "*" & [Forms]![frmSelection]![Text0] & "*" Or Is Null And The criteria is “Like "*" & [Forms]![frmSelection]![Text0] & "*" Or Is Null”.

The problem I have is that if I have a null value in frmSelection it returns all records. I want Access to add a value to any null text boxes on frmSelection and run the query on the click event so I there is a value in all text boxes when the query runs.
 
If I am understanding you correctly, in the click event before you run the query add the following code:

if isnull(me.text0) then
me.text0 = avalue
end if
if isnull(me.text2) then
me.text1 = anothervalue
end if
 
a Null plus anything else is Null. A Null times anything else is Null.

Nulls must be carefully used. Do use IsNull() or NZ() to 'defang' a Null.

Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top