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!

setting control source from possible null field

Status
Not open for further replies.

priapus

Technical User
May 17, 2001
26
0
0
US
I have a text box on a form whose control is the sum of two other text boxes on the form. When both source fields contain data, works fine. One of the source fields, however, is based on a Dsum statement that sometimes results in data but usually results in nothing. What's the easiest way to do this?
 
I would use an IIF function to test for the contents of the text boxes. If both are blank, then return "", if one is blank, only DSUM the other one, if neither one is blank, DSUM both.
 
You naughty person you.
Try this:
If IsNull(sourcefield) then
'Handle it one way
Else
'Handle it the other way
End if

That should do it
 
haha Art, I think you're the first person to figure that out. Since you can't enter the code builder for the control source of a field (that woulda made it easy) I used the IIF function in the expression builder. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top