2 Alterations needed to Report Code!

B

Bob

If someone could help I need to get the HorsesName from qryHorseList, Name
which has HorseID
and this code should only give the Base Result , latest Date
Thanks for any help......Bob

Private Sub Report_Open(Cancel As Integer)
Category.ControlSource = "='" & Form_frmMain.cbCategory & "'"
Me.RecordSource = "SELECT tblRemarks.dtDate, tblHorseInfo.HorseName,
tblRemarks.Category,tblRemarks.Remark " _
& " FROM tblRemarks INNER JOIN tblHorseInfo ON tblRemarks.HorseID =
tblHorseInfo.HorseID " _
& " Where Category='" & Form_frmMain.cbCategory & "'" _
& " ORDER BY tblRemarks.dtDate DESC; "
End Sub
 
O

Ofer Cohen

To get the path to a field in the form use
Forms!frmMain!cbCategory

But instead use the WhereCondition of the Open report command line

1. Base the RecordSource of the Report on the full data

SELECT tblRemarks.dtDate, tblHorseInfo.HorseName,
tblRemarks.Category,tblRemarks.Remark " _
FROM tblRemarks INNER JOIN tblHorseInfo ON tblRemarks.HorseID =
tblHorseInfo.HorseID

2. When you run the report add the filter

Dim MyCondition As String
MyCondition = "[Category]='" & Form_frmMain.cbCategory & "'
Docmd.OpenReport "ReportName" , , ,MyCondition

3. Set the Control Source of the Category field to Category, it should
display the right value because you filtered it on that value

4. To set the Order By, use the report Sorting and Grouping.
Select dtDate field and the order type
The sort using the RecordSource of the report won't always work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top