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

How to tell Access to check if Listbox is populated and then carry out

Status
Not open for further replies.

KennyUK

Technical User
Sep 13, 2001
38
GB
Hello,

I have a problem and I wondered if the experst of this group could help me out.

I have a list box on a form that to simple, I will call "List1" and the form is called "frm1".

I would like to tell Access to check if the list box has any data in it and if so then perform Task A
but if not perform Task B.

Can anyone tell me the correct method or syntax for doing this as I can not seem to get it right.

Thank you in advance,

Kenny
 
Hi KennyUK,

I'm not sure if I understand what you want but here it goes.

Access is a event Driven application and so are all its Classes and Objects. It means that you do not order Access to "spy" a list box. This function is embeded is the system, I mean, any Access object (text boxes, list boxes, combo boxes, forms, even labels, etc) has a collection of "triggers" that are executed accordingly with the action the user executs (Rigth-Click in the object and then select the Event Tab to see a list of possibles events to be used as triggers).

This means that as soon as the user clicks in the list box or start typing something a series of events will be checked and if you have a procedure (or macro) attached to that event it will be executed.

For a list box you have as "triggers":
Before Update, After Update, On Enter, On Exit, On Got Focus, On Lost Focus, On Click, On Double Click, On Mouse Down On Mouse Move, On Mouse Up, On Key Down, On Key Up, On Key Press.

You also have to keep in mind that this events occour in a specific order, depending naturally on the action taken by the user, example:

Enter -> Got Focus
Before Update -> After Update -> Exit -> Lost Focus

During all the time the user is editing a field you cant trigger Key Down -> Key Press -> Change -> Key Up

Hope it helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top