Using BVA to open and filter a report

Jak82

Registered User.
Local time
Today, 09:42
Joined
Jun 6, 2007
Messages
19
Hi There,

I have a main form which shows the students I have within my table, the form is set to continuos and has a button next to each record. This button opens the report and filter the report to the record clicked.

Problem is I do not know how to reference the record which has been selected.

Here is my code so far, but this just returns an empty report,

DoCmd.OpenReport "StudentInfo", acViewPreview, , "firstName = " & Firstname

regards

Chris
 
1) One way to do this is open the report itself and pass the filter in the OpenArgs using DoCmd.OpenReport

In the report's open event, do something like:

Code:
If Me.OpenArgs & "" = "" Then
    Me.FilterOn = False
Else
    Me.Filter = "FirstName='" & Me.OpenArgs & "'"
    Me.FilterOn = True
End If

2) If you do not wish to use the OpenArgs technique, try putting the value in quotes. i.e. "[firstName] = '" & Firstname & "'"
 

Users who are viewing this thread

Back
Top Bottom