Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Open Event Parameter Change

Status
Not open for further replies.

Bronte1226

Technical User
Oct 18, 2002
123
US
I am trying to change some code in a report that was made before I took over my position. The report has a parameter box that opens and runs a query to open the report based on the entry given in the message Box. I need to change this to run the report based on the current record instead of going through the message box. I have tried to change this myself but seem to keep missing a step that makes the report error out. Below is the code for the open event for the report. I hope someone can help!

Private Sub Report_Open(Cancel As Integer)
Dim strPointVar As String
Dim strPointID As String
strPointID = InputBox("Enter point in box below!", "Please Enter Control Point ID...")
If strPointID = "" Then
Cancel = True
End If
Dim query, arg
arg = strPointID
query = "SELECT * from tblMboroControlNetwork WHERE tblMboroControlNetwork.[pointid] = '" & arg & "'"
Me.RecordSource = query
End Sub
 
You'll need to replace the 'arg' with a reference to the current record ID field on your form(?):

Private Sub Report_Open(Cancel As Integer)
Dim query

query = "SELECT * from tblMboroControlNetwork WHERE tblMboroControlNetwork.[pointid] = '" & Me!MyField & "'"
Me.RecordSource = query
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top