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

problem with isnull

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB
I am trying to put code which checks if a combo box on a form is empty and if so puts the value from another field into it. the combo box in question has 2 columns (the bound column is the id field (auto number) and the other is the name field) the code I have is if isnull (me.cboallocatedto) then .....
and it is on the after update event of another combo box. It works fine if I clear the contents of the cboallocated field and then update the field with the code on it but when i try it on a new record where the cboallocated field is blank it doesn't work. I've stepped through the code and it seems it doesn't think it is null.

Can anyone help spot what I'm doing wrong??
 
Something of this nature in the onopen of the form:
Code:
dim c as integer

c = dcount("pirmarykey","tablename","where")

if c = 0 then
   me.mylist.rowsource = sqlstatement
end if

Hope this works

"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
oh woops.. instead of the onopen, use afterupdate

Sorry.


"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
its ok I'v spotted my problem. The id field in the main table was a number field and I hadn't noticed it was defaulting to 0. That is why it wasn't null unless I cleared it.

I now have another problem. I'm trying to open a form to a new record and put code on the onload event which will only apply if it is a new record. However when i put if me.newrecord = true then ..... - it doesn't seem to think it is a new record although it is.
 
I have no experience with the .newrecord, however you may want to look at .dataentry. I think it depends on how the form is opened and its properties.

Hope this works.


"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
For me, a better place to check the NewRecord property is the Current event procedure of the form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top