Display warning message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that should be based on the values in 2 combo boxes, that are not from any table. When I press the button to run report, i want to display a message that says 'You need to enter both parameters' and then not proceed. Can anyone tell me how to do this

Thanks in advance
 
maybe something like this:



Option Compare Database

Option Explicit

Private Sub btn_make_report_Click()


If Me.Combo0 = "" Or IsNull(Me.Combo0) Then

If Me.Combo1 = "" Or IsNull(Me.Combo1) Then

MsgBox "You must complete both combo boxes before the report can
be produced", vbExclamation

Exit Sub

End If

End If


'if the code gets this far due the combo boxes being populated properly
it will generate the report

'eg

DoCmd.OpenReport "myreport", acViewNormal



End Sub

KP said:
I have a report that should be based on the values in 2 combo boxes, that
are not from any table. When I press the button to run report, i want to
display a message that says 'You need to enter both parameters' and then not
proceed. Can anyone tell me how to do this?
 
Or u can put the following code On the On Open Event of The Form:

Sub Form_Open (Cancel AS integer)
Dim C As Access.Control
For Each C in Me.Controls
If TypeOf C is ComboBox Then
C.Value = C.ItemData(0)
End If
End Sub

This ensures a selection

Btw
Use
If Len(Nz(Control,""))=0 Then
...
End if
to check for Empty string & null in Access

in VB use
Len("" & Control) = 0

HTH

Pieter







KP said:
I have a report that should be based on the values in 2 combo boxes, that
are not from any table. When I press the button to run report, i want to
display a message that says 'You need to enter both parameters' and then not
proceed. Can anyone tell me how to do this?
 
Back
Top