View Full Version : List Box problem


aziz rasul
02-01-2001, 08:06 AM
On a form I have a listbox (with 2 columns) and a command button.

On opening the form, the user needs to select a record from the listbox before pressing the command button.

The purpose of this is that the first column contains date values which automatically go into the criteria row of a query. On pressing the button, a report is printed, dependent upon this date.

What code can I write to ensure that this is done. I'm not VBA literate, hence any code must be simple.

Thanks in advance.

pdx_man
02-01-2001, 10:52 AM
In the On Click event for the button

If Me.YourListBox.ItemsSelected.Count Then MsgBox "No Date selected. You must choose one to work with!"
Else
Do what you need to do if one is selected
endif

[This message has been edited by pdx_man (edited 02-01-2001).]

aziz rasul
02-02-2001, 07:23 AM
pdx_man,

That was great. I would never have worked that out. Many Thanks.