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

which event to use

Status
Not open for further replies.

alifyag

MIS
Apr 15, 2002
18
US
hi,
i have a combo box and a print command button.
i want the print command button to be disabled when nothing is chosen from the combo box however as as soon as somethign is chosen from the combo box, i want the command button to be enabled.
in which event should i do this.
thanks
 
Ali -

Assume combo box is empty (Null). User selects an item.
Button then becomes useable (enabled).

On the "AfterUpdate" of the combo box:

Me![MyButton].enabled = True
Exit Sub

On the "OnClick" event of the button make sure that the
User hasn't left the combo box empty for some reason and
then proceed with your printing...

If Not IsNull (Me!cboText) Then
DoCmd.OpenReport "rptMyReport", acViewPreview
Exit Sub
Else ' there is a null value left in cboText...
Me!cboText.SetFocus
Me!MyButton.enabled = False
Exit Sub
End If

...that should do it...you don't have to limit to list here, just check to make sure something is there...look out for users who put something in the combo box, then "delete" it, and then click on the button...cbo will not be a Null at that time...might have to check this...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top