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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access reports (same report different theme)

Status
Not open for further replies.

Swoop7

IS-IT--Management
Feb 7, 2003
3
IE
Hi,

I've got a number of variations on the same report. I don't want to recreate/copy the same report X times. I'd rather change the SQL via code. Is this possible?

Could someone post a snippet of code to get me started.

Thanks,
-Swoop
 
To answer my own question see below. Are there any better ways of doing this? Can I change the Query object a report uses dynamically/supply SQL?

See for the source of this code.

Option Explicit
Option Compare Database
Private Sub cmdLaunchTransactionReport_Click()
On Error GoTo Err_cmdLaunchTransactionReport_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim sCriteria
sCriteria = "[MemberId]=" & txtMemberId
stDocName = "rptTransactions"
DoCmd.OpenReport stDocName, acViewPreview, , sCriteria, acWindowNormal
Exit_cmdLaunchTransactionReport_Click:
Exit Sub
Err_cmdLaunchTransactionReport_Click:
msgbox Err.Description
Resume Exit_cmdLaunchTransactionReport_Click
End Sub
 
Well that's funny. Another answer to my own question:

Sub cmboCompanyName_AfterUpdate()
Dim strNewRecord As String
strNewRecord = "SELECT * FROM Customers " _
& " WHERE CustomerID = '" _
& Me!cmboCompanyName.Value & "'"
Me.RecordSource = strNewRecord
End Sub

Source this time is Access Help. I suppose this will work with Reports as well as forms.

-Swoop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top