Printing a single record to a report (1 Viewer)

daro

New member
Joined
Aug 24, 2015
Messages
3
Hi everybody.

I'm completely new when it comes to Access and SQL databases, so I hope you can help me out a bit:

I have started a project at my workplace, where I'm making a database over equipment that is provided for our users.

Now I no problems with setting up the reports for my tables, but I also want to be able to print out a single record in a table.

I've looked into it and so far found three solutions:

  • Create a command button and insert the following code: DoCmd.OpenReport "YourReportName", acViewNormal, , "[YourFieldName] = '" & Me.FieldName & "'"
  • Set up a macro manually (as seen in the post from Trevor G in www(dot)access-programmers(dot)co(dot)uk/forums/showthread.php?t=195641)
  • Create a button and insert the code in the VBA editor (www(dot)allenbrowne(dot)com/casu-15.html)
In the first solution, I get an "invalid value for the WHERE condition" error, in both the number and text code (I'm using the unique ID or an owner field linked to an unique ID).

In the second it's probably because of language barriers, but I'm very unsure on what I'm supposed to do. (If Trevor happens to see this thread, I would appreciate it if he had the time to provide pictures of the process :D)

With the third, I get the report with all the fields I want shown, but the data that should be in that record isn't shown. :banghead:

I hope you guys can help me find out exactly what and where I'm doing something wrong :D

P.S. Sorry about the links, but I can't post them yet :p
 

Trevor G

Registered User
Joined
Oct 1, 2009
Messages
2,331
Welcome to the forum,

I am on line and noticed your thread. I have created a database that you can download to see the example. If you open the form and then select a record and use the button it will display a single record in the report. If this is what you want look at the macro in design view you will see the details you need.

Good luck
 

Attachments

daro

New member
Joined
Aug 24, 2015
Messages
3
Thank you very much! I'll look into it :)
 

daro

New member
Joined
Aug 24, 2015
Messages
3
Weird. I couldn't get it to work with my database :banghead:
But I just started over and imported the data to a new one, and now it works like a charm.

Once again: Thank you so much!
 

Trevor G

Registered User
Joined
Oct 1, 2009
Messages
2,331
Happy to help and thank you for letting me know you have a working solution.
 

Lindak

New member
Joined
Jan 25, 2019
Messages
1
Thank you Trevor G :):):) for attaching PrintSingleRecord.accdb!!! I've been trying to figure out that for days. Was stuck on how to wrap a function around a variable in the where clause of the query builder, which wasn't working for me. This way was much easier. Now I just have to figure out how to get the report screen not to keep showing the same record unless I close the report each time I invoke it.
 

AmalJS

New member
Joined
Jul 30, 2019
Messages
1
Welcome to the forum,

I am on line and noticed your thread. I have created a database that you can download to see the example. If you open the form and then select a record and use the button it will display a single record in the report. If this is what you want look at the macro in design view you will see the details you need.

Good luck

Hi friend,

I tried this and after clicking the print button it is asking for "your query does not include the specified expression "First Name" as part of the aggregate function access."

:eek:
 

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

Top Bottom