Your technology certification is waiting. Enroll in Cloud Class ®
Private Sub Report_Open(Cancel As Integer)
Dim MyArgs() As String
Dim myDesiredField as string
Dim MyDesiredValue as string
Dim SQL as string
If Nz(Reports!rptMyReport.OpenArgs, "") <> "" Then
MyArgs() = Split(Reports!rptMyReport.OpenArgs, ",")
myDesiredField = Chr(34) & MyArgs(0) & Chr(34)
MyDesiredValue = Chr(34) & MyArgs(1) & Chr(34)
Select case true
Case myDesiredField = "Location"
SQL = "Select Distinct Animal, Location, "" as Attribute from tblMyTable where location like " & MyDesiredValue
Case myDesiredField = "Attribute"
SQL = "Select Distinct Animal, Location, Attribute from tblMyTable where Attribute like " & MyDesiredValue
Cancel = true
me.RecordSource = SQL
Open in new window
Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.