force listbox selection

L

LGarcia

Hi all,
I have a listbox on a form that is populated by a query when the form is
opened.
I also have a button that runs a few queries and opens a report based on the
value chosen from the listbox.
If the user doesn't choose a subject the report is empty. How can I make
sure the user makes a selection?
Thanks!
LGarcia
 
A

ALESSANDRO Baraldi

LGarcia said:
Hi all,
I have a listbox on a form that is populated by a query when the form is
opened.
I also have a button that runs a few queries and opens a report based on the
value chosen from the listbox.
If the user doesn't choose a subject the report is empty. How can I make
sure the user makes a selection?
Thanks!
LGarcia

You need to check ListIndex property.
If retValue=-1 no selection on ListBox, so you don't execute OpenReport...!

Alessandro(IT).
 
A

Albert D. Kallal

In your buttion code, just check for a null value.

if isnull(lstSubjects) = True then

msgbox "you must first select a subject"

exit sub

end

' code goes here to launch report....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top