C
Craig
I have one donor table and one donations table. I have two separate forms
to input the different types of donors (Company/Individual)
Each Donor form has a donations SubForm.
I want to do a query by form using the donation ID when clicking on a
command button.
Originally I had the following in the query and a command button to open the
query:
[Forms]![frmCompanies - LPS]![frmDonations]![DonationID]
Of course this would only work for the company form.
Without making another query (which would be the easy way round) is there
some way where I can change [frmCompanies - LPS] to a variable that selects
the current form.
I did try following VBA code but without any success.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("qryDonationsLetter")
qdf.Parameters(0) = Forms![frmCompanies - LPS]!frmDonations!DonationID
Set rst = qdf.OpenRecordset ' Open recordset on the query
If rst.RecordCount > 0 Then
DoCmd.OpenQuery "qryDonationsLetter"
End If
rst.Close
qdf.Close
End Sub
Thanks
Craig
to input the different types of donors (Company/Individual)
Each Donor form has a donations SubForm.
I want to do a query by form using the donation ID when clicking on a
command button.
Originally I had the following in the query and a command button to open the
query:
[Forms]![frmCompanies - LPS]![frmDonations]![DonationID]
Of course this would only work for the company form.
Without making another query (which would be the easy way round) is there
some way where I can change [frmCompanies - LPS] to a variable that selects
the current form.
I did try following VBA code but without any success.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("qryDonationsLetter")
qdf.Parameters(0) = Forms![frmCompanies - LPS]!frmDonations!DonationID
Set rst = qdf.OpenRecordset ' Open recordset on the query
If rst.RecordCount > 0 Then
DoCmd.OpenQuery "qryDonationsLetter"
End If
rst.Close
qdf.Close
End Sub
Thanks
Craig