Kamis, 30 Mei 2013

RE: [MS_AccessPros] How am I to tell the report to use the form�s record source?

 

Try,

Private Sub cmdOpenRpt_Click()
 
   Dim strWhere as String
   strWhere = Me.Filter
   DoCmd.OpenReport "RptCustomers", acViewPreview, ,strWhere , acWindowNormal

End Sub

Duane Hookom MVP
MS Access

----------------------------------------
> From: saigonf7q5@yahoo.com
>
> Hello Duane
>
> Here's the 2 procedures that in the form.
>
> combo box rowsource:
> SELECT DISTINCT qryCustomers.strCountry FROM qryCustomers;
>
> criteria which user enters:
> Private Sub cboCountry_AfterUpdate()
>
> Me.Filter = "strCountry = " & Chr$(34) & Me.cboCountry & Chr$(34) & ""
> Me.FilterOn = True
>
> 'Debug.Print Me.Filter
>
>
> End Sub
>
>
> Private Sub cmdOpenRpt_Click()
>
> Dim strCntryName As String
> strCntryName = Me.cboCountry
>
> DoCmd.OpenReport "RptCustomers", acViewPreview, , , acWindowNormal, strCntryName
>
> End Sub
>
>
>
> --- In MS_Access_Professionals@yahoogroups.com, Duane Hookom <duanehookom@...> wrote:
>>
>> Phucon,
>>
>> Tell us how you are using the combo box to filter the form records. I expect you could use a similar expression as a WHERE CONDITION in the DoCmd.OpenReport method.
>>
>> Duane Hookom MVP
>> MS Access
>>
>> ----------------------------------------
>>> From: saigonf7q5@...
>>>
>>> My form has a combo box for filtering records, and a Cmdbutton to open a report.
>>>
>>> I have been trying to pass the form's OpenArgs to the Report_Open procedue, so the report's Recordsource can base on the criteria that the user selected from the form. How am I to tell the report to use the form's record source?
>>>
>>> Below's what I have been trying to do.
>>>
>>> Private Sub cmdOpenRpt_Click()
>>>
>>> Dim strCntryName As String
>>>
>>> strCntryName = Me.cboCountry
>>>
>>> DoCmd.OpenReport "RptCustomers", acViewPreview, , , acWindowNormal, strCntryName
>>>
>>> End Sub
>>>
>>> Private Sub Report_Open(Cancel As Integer)
>>> Me.OpenArgs
>>> End Sub
>>>
>>> Thanks
>>> Phucon
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
.

__,_._,___

Tidak ada komentar:

Posting Komentar