force listbox selection

  • Thread starter Thread starter LGarcia
  • Start date Start date
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
 
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).
 
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....
 
Back
Top