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

Access VBA. Changing Report RecordSource 1

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
Dim strRecordSource As String

If Forms!fEOD!cmbPositionLevel = "-All-" Then
strRecordSource = "zzzz"
Reports("r").RecordSource = strRecordSource
DoCmd.OpenReport "r", acPreview


Simple question - why doesnt this work - what is the correct code?

THanks a million
 
You have to open the report before you can set it's RecordSource. Enter This Code into the OnOpen Event procedure in report "r":

Private Sub r_Open(Cancel as Integer)
Select Case Forms("fEOD")![cmbPosisitonLevel]
Case "-All-"
me.recordsource = "zzzz"
Case ...
me.recordsource = ...
end select
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top