Filter all but one field

T

Tal

Hello,

I am making a donation database where many of the donors have multiple
addresses. I am creating the Edit Donor form and have filtered it using the
following code (This is my first foray, so it might not be pretty)

The cboAddressLabel field identifies the specific address. Within this
address I have a lookup field that calls a province/state table that contains
a list of Provinces and States. However, when I select this combo box in my
form it only contains those provinces that have been previously selected
(meaning, it is limited to the contents of the query) more specifically - I
have Ontario listed four times. I have set the record source of the field to
the province state table, but nothing seems to be working. Help!!!!

Private Sub cboSearchDonor_AfterUpdate()
Dim strWhere As String
Const strcStub = "SELECT * FROM qryDonorsandAddresses "

If Not IsNull(Me.cboSearchDonor) Then
strWhere = "WHERE (keyDonor = " & Me.cboSearchDonor & ")"
End If
Forms![frmAddorEditDonors].RecordSource = strcStub & strWhere
End Sub

Private Sub cboSearchDonor_LostFocus()
Dim SAddressLabel As String
SAddressLabel = "SELECT [qryDonorsandAddresses].[keyDonorAddress],
[qryDonorsandAddresses].[txtAddressLabel] " & _
"FROM qryDonorsandAddresses " & _
"WHERE [qryDonorsandAddresses].[keyDonor] = " &
Me.cboSearchDonor.Value
Me.cboAddressLabel.RowSource = SAddressLabel
Me.cboAddressLabel.Requery
Me!cboSearchDonor.Value = ""

End Sub

Private Sub cboAddressLabel_AfterUpdate()
Dim strWhere As String
Const strcStub = "SELECT * FROM qryDonorsandAddresses "
Const strcTail = "SELECT * FROM tblProvinceState "

If Not IsNull(Me.cboAddressLabel) Then
strWhere = "WHERE (keyDonorAddress = " & Me.cboAddressLabel & ")"
End If
Forms![frmAddorEditDonors].RecordSource = strcStub & strWhere & strcTail
End Sub
 
T

Tal

I am going to addendum my own post.
I have other lookup fields that are doing the same thing.

Thank you!!
 

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

Top