Displaying Record in Report (1 Viewer)

MNM

Registered User.
Local time
Tomorrow, 07:06
Joined
Mar 3, 2014
Messages
61
Greetings,
I am new to access and have found some great tip sites online, including this one.
However, I cannot find a tip on what I am trying to accomplish at this time.

I am unsure as to post this as it pertains to reports, forms and VBA, so if it gets moved I hope I get an email informing me this;).

I have a report, which opens a dynamic search form (built off of John Big Booty's code from this site). The form opens, and works as expected.

During the dynamic search form testing, I created an 'OK' button that opens another form to display the record, but the dynamic search was opened first.

I would like to reprogram the button to display the selected record in the report which opened it.

The problem: How can I get the selected record to display in the already open report?

BTW, The company I work for uses MSOffice 2003 on XP machines:banghead:.

TIA,
MNM
 
CanadianAccessUser,
Thanks for the tip, it may come in handy later when the DB is up & running.
Upon looking at the web page, I fail to see how this can port the selected record to the report which opened the search form.
MNM
 
Set your button to requery the open report and set the report to pull information from the combo boxes in the form that has your record chosen.
If I am wrong then I appologize for leading you in the wrong direction, but I've done this before and it worked wonderfully. :)
 
I have a report, which opens a dynamic search form (built off of John Big Booty's code from this site). The form opens, and works as expected...

...I would like to reprogram the ['OK'] button to display the selected record in the report which opened it.

The problem: How can I get the selected record to display in the already open report?

When I do this with a form, it works perfectly.
  • "The user" opens the form.
  • The form launches the dynamic search form.
  • When OK is clicked, the selected record is displayed in the first form.

When I try this with a report, it does not work as above.
The code for the form OK button is:
Code:
  Me.Visible = False
  
  Dim stDocName As String
  Dim stLinkCriteria As String
  
  stDocName = "{FORM NAME}"
  stLinkCriteria = "[Employee Number]='" & Me![SearchResults] & "'"
  
  DoCmd.OpenForm stDocName, , , stLinkCriteria

The code for the report OK button is:
Code:
  Me.Visible = False
  
  Dim stDocName As String
  Dim stLinkCriteria As String
  
  stDocName = "{REPORT NAME}"
  stLinkCriteria = "[Employee Number]='" & Me![SearchResults] & "'"
  
  DoCmd.OpenReport stDocName, , , stLinkCriteria

This generates an 'Error 2585'. Debugging highlights the "DoCmd.OpenReport stDocName, , , stLinkCriteria"

How come the same 'code' works with a form and not a report?:confused:

Thanks for the help,
MNM
 
First off is "Form Name" the real name of your form?
And is "Report Name" the real name for a report? If so change the brackets to [ ]. Probably MS reserved words BTW.

No they are not, I put those labels in lieu of the actual names, hence the {} surrounding them. As stated, the code works for the forms; I have 3 separate ones, Form+Search+Query, up and running. The third I made yesterday to replace the report, as this seems to be the best solution, and I'll port the info to the report with a button.
MNM
 
The third I made yesterday to replace the report, as this seems to be the best solution, and I'll port the info to the report with a button.
MNM

Update: This does it. However, I still want to port the record directly to the report.
So, why can't the same procedure for the form work for the report?
 
When you post code wrapped in code tags, the reader makes certain assumptions about your code. We have no way of knowing you have substituted pseudo code or special symbols.

Sorry about that, I was unsure of actual protocol.

Usually forms open reports. Unless I am missing something.

This is what I ended up doing.

Thanks for the help!
MNM
 

Users who are viewing this thread

Back
Top Bottom