| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
printing single record reports
I have a print button on my form using the following code to print a single record report:
Code:
Private Sub Command26_Click() Dim strDocName As String Dim strLinkCriteria As String DoCmd.RunCommand acCmdSaveRecord strDocName = "InventoryTagBusway" strLinkCriteria = "ID = Forms![BUSWAY]![ID]" DoCmd.OpenReport strDocName, acViewPreview, , strLinkCriteria End Sub Private Sub Form_Current() |
| Sponsored Links |
|
#2
|
||||
|
||||
|
You can use a UNION query as your source for your report:
SELECT * FROM table1 UNION SELECT * FROM table2 UNION SELECT * FROM table3 etc... If you want to be able to identify which table each record came from then add a column: SELECT "t1" as [tableID], * FROM table1 UNION SELECT "t2" as [tableID], * FROM table2 UNION SELECT "t3" as [tableID], * FROM table3 etc... hth Stopher |
|
#3
|
|||
|
|||
|
sorry, newb here. Can you help me with implementing this?
|
|
#4
|
||||
|
||||
|
I might be making too many assumptions about the "shape" of your data. Perhaps you could post your database and we can do it on the real thing.
Stopher |
|
#5
|
|||
|
|||
|
here is a stripped down version, you'll notice all of the reports have the same fields and layout. I am trying to have just one report that chooses the fields from the appropriate table based on which form the "print label" button is being pressed from.
Last edited by btappan; 03-19-2007 at 05:17 PM.. |
|
#6
|
||||
|
||||
|
Are you using Access 2007 ? I'm sorry I don't have that version so I can't examine your file. Perhaps you have the option to convert it to a previous version of Access...
Stopher |
|
#7
|
|||
|
|||
|
all right, i replaced the file above with a 2003 version.
|
|
#8
|
||||
|
||||
|
The first point is that your ID is really just a number despite the fact that you are formatting it. So when you come to join data together, this formatting will be lost and you will just see 1,2,3 etc and you won't be able to tell the difference between the data from different tables. Therefore it is worth looking at a more robust system for capturing/storing your primary key. It there are many posts in the forums on this (do a search on “autonumber”) and you’ll see some discussion on different approaches/views. In order to deal with this for now, I’ve created the query such that the format you want is generated by the query and therefore becomes useable. Also look at Bob Larson's response in a previous post of yours here as it explains how better to model what you are doing i.e. putting all "items" in one table and storing attributes in another.
In the attached d/b I have created a union query (qryCombinedTableView). A query allows you to view tables in different ways and generally reports and forms will be based on queries rather than directly on tables. You can look at it in design mode and also run it and you will see how it has combined your tables. Also, if you look at the new report (InventoryTagALL) and look at the record source, you will see that I’ve reference the new query here (rather than a table). You can use the new query as the source of all your reports for the time being. It’s worth reading up on queries as they are the workhorse of relational databases. Stick with it. Access and relational databases isn't something that you learn overnight. Every now and again the penny will drop and you'll find yourself taking a big step forward. Stopher |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Update Previous Record From Single View Subform | jwleonard | Forms | 4 | 02-19-2007 08:35 AM |
| Printing a report based on the current (new) record | Dougalsworld | Forms | 2 | 11-23-2006 05:04 AM |
| Printing Just one Record | nbaj | Reports | 3 | 12-06-2004 12:04 PM |
| Protect a single record | Numpty | General | 6 | 06-26-2003 12:16 PM |
| Multiple Reports, One Record At A Time | Old Gnome | Reports | 11 | 08-22-2001 12:20 PM |