Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-16-2007, 09:44 AM
btappan btappan is offline
Registered User
 
Join Date: Feb 2007
Posts: 40
btappan is on a distinguished road
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()
I know i'm breaking the Normalization rules but for now (i'm repairing a database line by line) i have about 10 tables each with about 10 fields, ALL 10 tables have 3 fields that are the same, and only those 3 fields are being printed for the report for any of the tables. I have 10 reports that all look the same to go with each table's 3 records. How can I use 1 report for this instead of 1 for each table? each time I adjust the page formatting, i have 2 do it for all 10 . Thanks
Reply With Quote
Sponsored Links
  #2  
Old 03-17-2007, 12:26 AM
stopher's Avatar
stopher stopher is offline
AWF VIP
 
Join Date: Feb 2006
Location: Southampton, UK
Posts: 1,033
stopher has a spectacular aura aboutstopher has a spectacular aura about
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
Reply With Quote
  #3  
Old 03-18-2007, 07:43 PM
btappan btappan is offline
Registered User
 
Join Date: Feb 2007
Posts: 40
btappan is on a distinguished road
sorry, newb here. Can you help me with implementing this?
Reply With Quote
  #4  
Old 03-19-2007, 06:17 AM
stopher's Avatar
stopher stopher is offline
AWF VIP
 
Join Date: Feb 2006
Location: Southampton, UK
Posts: 1,033
stopher has a spectacular aura aboutstopher has a spectacular aura about
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
Reply With Quote
  #5  
Old 03-19-2007, 06:48 AM
btappan btappan is offline
Registered User
 
Join Date: Feb 2007
Posts: 40
btappan is on a distinguished road
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.
Attached Files
File Type: zip trial.zip (70.3 KB, 22 views)

Last edited by btappan; 03-19-2007 at 06:17 PM..
Reply With Quote
  #6  
Old 03-19-2007, 03:12 PM
stopher's Avatar
stopher stopher is offline
AWF VIP
 
Join Date: Feb 2006
Location: Southampton, UK
Posts: 1,033
stopher has a spectacular aura aboutstopher has a spectacular aura about
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
Reply With Quote
  #7  
Old 03-19-2007, 06:18 PM
btappan btappan is offline
Registered User
 
Join Date: Feb 2007
Posts: 40
btappan is on a distinguished road
all right, i replaced the file above with a 2003 version.
Reply With Quote
  #8  
Old 03-20-2007, 02:59 AM
stopher's Avatar
stopher stopher is offline
AWF VIP
 
Join Date: Feb 2006
Location: Southampton, UK
Posts: 1,033
stopher has a spectacular aura aboutstopher has a spectacular aura about
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
Attached Files
File Type: zip trial2003.zip (76.5 KB, 19 views)
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Previous Record From Single View Subform jwleonard Forms 4 02-19-2007 09:35 AM
Printing a report based on the current (new) record Dougalsworld Forms 2 11-23-2006 06:04 AM
Printing Just one Record nbaj Reports 3 12-06-2004 01:04 PM
Protect a single record Numpty General 6 06-26-2003 01:16 PM
Multiple Reports, One Record At A Time Old Gnome Reports 11 08-22-2001 01:20 PM


All times are GMT -8. The time now is 04:49 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World