"hollyylloh" <(E-Mail Removed)> wrote in message
news:35109FF8-CB03-424F-B22F-(E-Mail Removed)...
>I have been assigning the control source to my reports in code like this:
>
> If Me!ClientID = "ABC" Then
> DoCmd.OpenReport "rptABC", acViewDesign
> Reports!rptABC.RecordSource = "qryABC"
> DoCmd.Save acReport, "rptABC"
> DoCmd.OpenReport "rptABC", acViewPreview
> Else...
>
> However, I need to convert the database to an mde file, thus removing the
> ability to go into design view. Is there another way to assign the control
> source of a report in code? This way will not work with an mde file
> because
> it tries to enter design view.
Pass the desired recordsource to the report via OpenArgs:
DoCmd.OpenReport "rptABC", acViewPreview, _
OpenArgs:="qryABC"
In the report's Open event, get the value of OpenArgs and assign it to the
RecordSource property:
Private Sub Report_Open(Cancel As Integer)
Dim stArgs As string
strArgs = Me.OpenArgs & vbNullString
If Len(strArgs) > 0 Then
Me.RecordSource = strArgs
End If
End Sub
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)