If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Refering to two different tables depending on date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-31-03, 07:23
bertthefreak bertthefreak is offline
Registered User
 
Join Date: Dec 2003
Location: Belfast, UK
Posts: 87
Refering to two different tables depending on date

Is it possible to create code so that when i run a query/report it can refer to two different tables depending on the date.

Example the user keys date the data is keyed, when running the report I want it to read from table A if the date keyed is before 01/01/04 and table B if the date keyed is After 01/01/04

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-31-03, 07:38
M Owen M Owen is offline
Grand Poobah
 
Join Date: Sep 2003
Location: MI
Posts: 3,713
Yes. In the Report_Open method pull the date and test it and set your RecordSource accordingly...
Reply With Quote
  #3 (permalink)  
Old 12-31-03, 07:40
bertthefreak bertthefreak is offline
Registered User
 
Join Date: Dec 2003
Location: Belfast, UK
Posts: 87
I'm sorry I don't know how to do this.
Reply With Quote
  #4 (permalink)  
Old 12-31-03, 07:43
garethdart garethdart is offline
Registered User
 
Join Date: Sep 2002
Location: South Wales
Posts: 580
Try this

Does the user key the date on a form then click print report?

IF so, dump this code in the report_open event:
(Change the formnamewithuserinput.fieldnamefromthisfor to correspond to your form and field / textbox names)

Private Sub Report_Open(Cancel As Integer)

If Forms!formnamewithuserinput.fieldnamefromthisform < #1/1/2004# Then
Me.RecordSource = "tablename"

Else
Me.RecordSource = "othertablename"

End If

End Sub
__________________
Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull
Reply With Quote
  #5 (permalink)  
Old 12-31-03, 07:48
bertthefreak bertthefreak is offline
Registered User
 
Join Date: Dec 2003
Location: Belfast, UK
Posts: 87
no when they key the original data the keyed the date the information was keyed, this is included in the report. What's happening is we are restructuring the company so that different outlet now fall in different areas. but for the reports we still need to be able to retain the old data as well as the new.

I have created a new table with the new network structure leaving the previous table intact.
Reply With Quote
  #6 (permalink)  
Old 12-31-03, 07:55
garethdart garethdart is offline
Registered User
 
Join Date: Sep 2002
Location: South Wales
Posts: 580
Lightbulb Query

Could the report contain data from both tables?

If so create a query to pool data from both tables and use the query as the recordsource for the report?
__________________
Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On