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

Problem with "listname.value" vba code

Status
Not open for further replies.

vanHel

Programmer
Apr 19, 2004
13
DE
Thanks in advance for any help!!!
I use the expression 'listname.value' in an 'if' construction in vba code to remove entries from a list in a form by clicking on a button. 'Listname.value' returns a unique id for each entry of the list that is selected (by the user) in the form. When the last entry of the list was removed, at any following click on the button a msgbox should let the user know that the order could not be processed due to an empty list. The problem occurs when the list is empty. After having removed the last entry of the list, at any following click on the button 'listname.value' contains the id of the last entry that was removed from the list. As the list is empty it should contain 'null'.
Do I have to refresh 'listname.value' in a special way? Or is there a special option?

I appreciate any help!
 
Hi..

You could check for the number of items in the list before processing the removal such as..

If me.list1.listcount > 0 then

your code

else

do nothing or msg

end if
 
Thanks lewds for the hint!

As it is important for me to know if an item of the list is marked and not only if the list contains values I added 'listname.value =""' at the end of the if construction. That seems to work without error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top