Report Button to bring up corrosponding record? (1 Viewer)

Status
Not open for further replies.

MayaMana

Registered User.
Local time
Today, 09:31
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.:eek:
 
Last edited:

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:31
Joined
Feb 19, 2002
Messages
28,774
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.
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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:

Bryan

Registered User.
Local time
Today, 09:31
Joined
May 7, 2012
Messages
124
Is there a space in the middle of FieldName?
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
No and when I go to edit that on here it looks normal :-/
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:31
Joined
Aug 30, 2003
Messages
34,062
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.
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:31
Joined
Aug 30, 2003
Messages
34,062
You forgot the ampersand to connect them.
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
Private Sub Command5_Click()
DoCmd.OpenReport("Report2",acViewNormal,,"ProcessChangeID = '" & Me.PCid & "'",acWindowNormal,OpenArgs)
End Sub

and I am back to the
Compile error: expected =
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:31
Joined
Aug 30, 2003
Messages
34,062
Does this work?

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

I assume the ID field is text?
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:31
Joined
Feb 19, 2002
Messages
28,774
I thought you said you wanted to preview rather than print.
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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:

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:31
Joined
Aug 30, 2003
Messages
34,062
Are you sure it's text? The error implies otherwise. Can you post the db here?
 

MayaMana

Registered User.
Local time
Today, 09:31
Joined
May 29, 2012
Messages
60
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:

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:31
Joined
Aug 30, 2003
Messages
34,062
Happy to help.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom