msgbox when cbx is null

steve1111

Registered User.
Local time
Today, 14:19
Joined
Jul 9, 2013
Messages
170
Hi,

I have a form with a cbx (Reportcbx) that list a series of forms, then i have a subform "Reportctrl" that loads the form from the Reportcbx. How do you prompt a msgbox of the user clicks run button before selecting a report from the Reportcbx, aka Reportcbx is null? I have currently:

If Reportcbx = Null Then
DoCmd.OpenForm ("Please select a report")
Else
Me.ReportCtrl.SourceObject = Me.Reportcbx
End If

I am getting a run time error 94 Invalid use of null

Any help is appreciated.
 
I generally use:

If Len(Me.Reportcbx & vbNullString) = 0 Then
 
Perfect, thanks so much
 
Happy to help. You could use IsNull(), but the above tests for both Null and a zero length string ("").
 
I assume your code is in the On Click event of the button. You could try:
Code:
If IsNull(Me.Reportcbx) Then
  Msgbox "Please select a report"
  Me.Reportcbx.SetFocus
Else
  Me.ReportCtrl.SourceObject = Me.Reportcbx
End If
but perhaps it would be better to set the buttons Enabled property to No and use some code to enable the button in the After Update event of the combo box.
 
Sorry, missed the last two posts. Never could type very fast :)
 

Users who are viewing this thread

Back
Top Bottom