Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnClick, Option=True, RunMacro

Status
Not open for further replies.

eddmon

Programmer
Apr 2, 2002
10
0
0
US
I have two reports. One uses a baseline set of dates, the other uses adjusted dates. Both utilize a query that is filtered from a QBF. I use a button on a form for each report that is generated by a macro to include the query as a filter and display the report in PrintPreview. I've treid umteen different "If...Then...Else (ElseIf)" and "IIf" statements. I'm close, but no cigar.
I'd like an option button (or checkbox) that gives the different date options when you click a single button to get the report. Here's where I'm at:
Private Sub Command264_Click()
'If Option Button is checked, run Report with Scheduled Green Tag Dates
If (Me!SGTOption = True) Then DoCmd.RunMacro "Mcr: OpenEquipmentList_S-OAT_NotElect_D1D"
If (Me!SGTOption = False) Then DoCmd.RunMacro "Mcr: OpenEquipmentList_A-OAT_NotElect_D1D"
End Sub
 
To others: Please reply to this as well. My solution is not necessarily the most efficient.

(1) In the help of your version of Access look up the topic "Use a form to enter report criteria"

(2) Copy and paste your data table. Name the pasted table as [tblTemp Data]. On the "OK" command button build your SQL that will delete the existing data in your Temp table and append the queried data selected from the form into the Temp table. Use runsql and execute once for the delete criteria and again for the append criteria.

(3) Build your queries and report on the Temp table, not the full data information table.

Effectively what you are doing is this:

1 - build a sub-set of data that you run your criteria on that is the basis for your queries, that are the basis for your report. One report format, 1000 different ways...

Good Luck! It's a fun, detailed process. (Get used to writing SQL)

SATHandle [sunshine]
 
Interesting approach using SQL and a TempTable. I do believe there's a simpler methodology down the avenue I’ve already started down, but I’ll play with your idea just to see how it works. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top