Mansoor Ahmad
Registered User.
- Local time
- Today, 05:05
- Joined
- Jan 20, 2003
- Messages
- 140
Dear All
On my form there is an option group named specialreports. Then there are combo boxes linked to each option.
Private Sub OptSpecialreports_BeforeUpdate(Cancel As Integer)
Me.CmbCustomer1 = Null
Me.CombPallno = Null
Me.Cmbmodel = Null
Me.txtDatefrom = Null
Me.txtTo = Null
Me.CmbCustomer2 = Null
End Sub
Private Sub PrintIt(rptName As String)
Dim stWhere As String
Dim myInt As String
Select Case Me!OptSpecialreports
Case 1
myInt = Forms![New form Sample]!CmbCustomer1
stWhere = "[CUSTOMER] = '" & myInt & "'"
Case 2
myInt = Forms![New form Sample]!CombPallno
stWhere = "[PALL No] = '" & myInt & "'"
Case 3
myInt = Forms![New form Sample]!Cmbmodel
stWhere = "[MODEL CODE] = '" & myInt & "'"
Case 4
myInt = Forms![New form Sample]!CmbCustomer2
stWhere = "([RUN DATE/CONCERN ISSUE DATE]Between [txtDatefrom] And [txtTo]) And ([CUSTOMER]= '" & myInt & "')"
Case Else
stWhere = ""
End Select
DoCmd.OpenReport (rptName), acViewPreview, , stWhere
End Sub
If I leave a combo box empty, it prompts as an error
'Invalid use of Null'
What I want is if a combo box is left blank it would display a msgbox asking to select data from combo box first.
I do understand that as [myInt] has been defined as a variable and apparently a variable cannot have a null value. But how can I inform the user to select or insert some data first before proceed and not let auto error message display.
Looking forward to suggestions.
On my form there is an option group named specialreports. Then there are combo boxes linked to each option.
Private Sub OptSpecialreports_BeforeUpdate(Cancel As Integer)
Me.CmbCustomer1 = Null
Me.CombPallno = Null
Me.Cmbmodel = Null
Me.txtDatefrom = Null
Me.txtTo = Null
Me.CmbCustomer2 = Null
End Sub
Private Sub PrintIt(rptName As String)
Dim stWhere As String
Dim myInt As String
Select Case Me!OptSpecialreports
Case 1
myInt = Forms![New form Sample]!CmbCustomer1
stWhere = "[CUSTOMER] = '" & myInt & "'"
Case 2
myInt = Forms![New form Sample]!CombPallno
stWhere = "[PALL No] = '" & myInt & "'"
Case 3
myInt = Forms![New form Sample]!Cmbmodel
stWhere = "[MODEL CODE] = '" & myInt & "'"
Case 4
myInt = Forms![New form Sample]!CmbCustomer2
stWhere = "([RUN DATE/CONCERN ISSUE DATE]Between [txtDatefrom] And [txtTo]) And ([CUSTOMER]= '" & myInt & "')"
Case Else
stWhere = ""
End Select
DoCmd.OpenReport (rptName), acViewPreview, , stWhere
End Sub
If I leave a combo box empty, it prompts as an error
'Invalid use of Null'
What I want is if a combo box is left blank it would display a msgbox asking to select data from combo box first.
I do understand that as [myInt] has been defined as a variable and apparently a variable cannot have a null value. But how can I inform the user to select or insert some data first before proceed and not let auto error message display.
Looking forward to suggestions.