Using a button to open a report off a specific form's record (1 Viewer)

vhanus2

Registered User.
Local time
Yesterday, 23:28
Joined
Aug 13, 2018
Messages
10
Hello,

Im currently trying to create a button on a form that would open the record in a report, and one that would eventually print said record.

I currently have the button working; however, its asking for a parameter.

if any one has any suggestions it would be helpful.

My current macro for this is:

OpenReport
Report Name rptCB-S
View Print Preview
Filter Name
Where Conditon =[CB(S)ID]=[Forms]![fmCB-S]![CB(S)ID]
Window Mode Normal
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:28
Joined
Aug 30, 2003
Messages
36,125
The parameter prompt is Access telling you it can't find something, so double check the spelling. I don't use macros, so not sure of the exact syntax required. It would look like this in VBA:

http://www.baldyweb.com/wherecondition.htm
 

vhanus2

Registered User.
Local time
Yesterday, 23:28
Joined
Aug 13, 2018
Messages
10
Paul,

I've tried using the VBA, and it is coming back with a Invalid Outside Procedure error.

This is the code:
Code:
Private Sub Command465_Click()
DoCmd.OpenReport "rptCB-S", acViewPreview, , "[CB(S)ID]=" & Me.[CB(S)ID]

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:28
Joined
Aug 30, 2003
Messages
36,125
There must be more. What's the entire module's code? If you hit Debug/Compile..., what line is highlighted?
 

vhanus2

Registered User.
Local time
Yesterday, 23:28
Joined
Aug 13, 2018
Messages
10
There is no option for Debug/compile--this is the error:
the expression after update you entered as the event property setting produced the following error: invalid outside procedure.
the expression may not result in the name of the macro, the name of a user-defined function, or [event procedure]
there may habe been an error evaluating the function, event, or macro.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:28
Joined
Aug 30, 2003
Messages
36,125
I meant to do that before testing. It sounds like there's code someplace else causing the error, as that looks okay to me. Can you attach the db here?
 

vhanus2

Registered User.
Local time
Yesterday, 23:28
Joined
Aug 13, 2018
Messages
10
Here you go.
 

Attachments

  • DBCOPY.accdb
    1.7 MB · Views: 97

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:28
Joined
Aug 30, 2003
Messages
36,125
You've got a stray End Sub above this sub that needs to be deleted:

Code:
Option Compare Database

[COLOR="Red"]End Sub[/COLOR]

Private Sub Command465_Click()
DoCmd.OpenReport "rptCB-S", acViewPreview, , "[CB(S)ID]=" & Me.[CB(S)ID]

End Sub

Also:

http://www.baldyweb.com/OptionExplicit.htm
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:28
Joined
Aug 30, 2003
Messages
36,125
Happy to help and welcome to the site by the way!
 

Users who are viewing this thread

Top Bottom