Combo box and/or option in option gp

Mansoor Ahmad

Registered User.
Local time
Today, 23:14
Joined
Jan 20, 2003
Messages
140
Dear All

On my form I have an option group, a combo box and 3 command buttons to open reports depending on what is selected in combo box and in optios. What I want to do is

Reports can be viewed based on selection in combo box alone
Reports can be viewed based on selection in combo box and an option in op group
Reports can be viewed base on selection in option group alone

I have put the following code. On clicking on command button, it prompts sometimes
'Invalid use of Null" or
'Date mismatch'

Private Sub PrintIt(rptName As String)

Dim stWhere As String
Dim myInt As String
Dim myInd As String

myInd = Forms![Form2]!CmbCustomer

Select Case Me!frmHVAC
Case 1
stWhere = ("[REJECT DATE]Between [date from] And [to]") And (" [CUSTOMER]= '" & myInd & "'") Or ("[CUSTOMER] = '" & myInd & "'") Or ("[REJECT DATE]Between [date from] And [to]")
Case 2
stWhere = ("[ANALYSIS DATE]Between [date from] And [to]" And " [CUSTOMER]= '" & myInd & "'") Or ("[CUSTOMER] = '" & myInd & "'") Or ("[ANALYSIS DATE]Between [date from] And [to]")
Case 3
myInt = Forms![Form2]!CmbLiabcat
stWhere = ("[CAT] = '" & myInt & "'" And " [CUSTOMER]= '" & myInd & "'") Or ("[CUSTOMER] = '" & myInd & "'") Or ("[CAT] = '" & myInt & "'")

Case 4
myInt = Forms![Form2]!CmbRejcode
stWhere = ("[REJ CODE] = '" & myInt & "'" And " [CUSTOMER]= '" & myInd & "'") Or ("[CUSTOMER] = '" & myInd & "'") Or ("[REJ CODE] = '" & myInt & "'")

Case Else
stWhere = ""
End Select
DoCmd.OpenReport (rptName), acViewPreview, , stWhere


End Sub

I am not good in VB codes at all. Can somebody please give some suggestion.

Thanks
 

Users who are viewing this thread

Back
Top Bottom