Report Button to bring up corrosponding record?

Status
Not open for further replies.

MayaMana

Registered User.
Local time
Yesterday, 19:33
Joined
May 29, 2012
Messages
60
I have report page that pretty much brings up a summary of multiple records.
It would be nice to be able to push a button next to the summary and have it pull up the full report of the record it is next to.
I have the full record page asking for id number right now, but I was wondering if there is a way to make it so that the button automatically enters in the value without the operator having to.:o
 
Last edited:
I don't know why, but when I put that in it is trying to print out the report :-/

I used the code

Private Sub Command_Click()
DoCmd.OpenReport "SecondReportName", , , "FieldName = '" & Me.ControlName & "'"
End Sub
 
Last edited:
Code:
DoCmd.OpenReport "SecondReportName", acViewPreview, , "FieldName = '" & Me.ControlName & "'"

As you type the command, you will see intellisense for each argument. I chose the preview option. You might want something else.
 
Okay, I changed it to follow how access suggested.
It now looks like:

DoCmd.OpenReport(ReportName,acViewNormal,,"FieldName = '" & Me.ControlName = "'",acWindowNormal,[OpenArgs])

But now I get and Error message:

Compile Error:
Expected: =
 
Last edited:
Is there a space in the middle of FieldName?
 
No and when I go to edit that on here it looks normal :-/
 
For starters, you need to replace the various names with yours. Second review the syntax against the examples given. You've added extra parentheses and =, and missed quotes.
 
For starters, you need to replace the various names with yours. Second review the syntax against the examples given. You've added extra parentheses and =, and missed quotes.


Private Sub Command5_Click()
DoCmd.OpenReport("Report2",acViewNormal,,"ProcessChangeID = '" & Me.PCid "'",acWindowNormal,OpenArgs)
End Sub

Compile error:
Expected:list separator or )

the red is what is highlighted when the error comes up.
It is ProcessChangedID no spaces in the actual code.
 
You forgot the ampersand to connect them.
 
Private Sub Command5_Click()
DoCmd.OpenReport("Report2",acViewNormal,,"ProcessChangeID = '" & Me.PCid & "'",acWindowNormal,OpenArgs)
End Sub

and I am back to the
Compile error: expected =
 
Does this work?

DoCmd.OpenReport "Report2",acViewNormal,,"ProcessChangeID = '" & Me.PCid & "'"

I assume the ID field is text?
 
Does this work?

DoCmd.OpenReport "Report2",acViewNormal,,"ProcessChangeID = '" & Me.PCid & "'"

I assume the ID field is text?
I end up getting
Run-time error '3464':
Data type mismatched in criteria expression.

Debug highlights the whole line.

ProcessChangeID field is text. It is not the primary ID auto-number access gives it if that is what you are wondering.
 
Last edited:
I thought you said you wanted to preview rather than print.
 
I thought you said you wanted to preview rather than print.

Yes, well I want to bring up the report in report view not preview print. However I am still unable to get the code to bring up the report. Instead I keep getting error messages.:banghead:
I'm still learning all of this stuff, so what I am trying to do might not be possible.
 
Last edited:
Are you sure it's text? The error implies otherwise. Can you post the db here?
 
Are you sure it's text? The error implies otherwise. Can you post the db here?

Thats what I have it set as...
I am working on making it small enough to attach as a zip file to add on here.

Well after looking over it again I did have that set to one of the number fields, completely forgot I had it formatted and bringing up just the number used rather then the whole .
Thank you for having me double check that again.

This is the code I ended up using:
Private Sub Command7_Click()
DoCmd.OpenReport "Report2", acViewReport, , "GCid = " & Me.PCid
End Sub
 
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom