Requery a combo box to find records

S

steve

I have a combo box that looks up people. I also have a lable control,
courtesy of Stephen Lebans site, that filters the form records by the letter
chosen. The lable control works fine and the combo box did before I added
the lable control.

What I would like to accomplish is to do a primary filtering with the lable
control, restricting the records to people with last name starting with A or
B or C.... Then using the combo box to pick a record from that subset of
records. My current code is below.

****This Code works****

Private Sub lblAlpha_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)



Me.Filter = "[LastName] LIKE " & Chr(34) & Chr(64 - Int(-X /
Me.lblAlpha.Width * 26)) & "*" & Chr(34)

Me.FilterOn = True

Me.txtAlpha = Left([LastName], 1)





End Sub

****This code does not work****
Private Sub cboPatientLookup_AfterUpdate()

' Find the record that matches the control.

Me.FilterOn = False

Dim rs As Object

Set rs = Me.Recordset.Clone

rs.FindFirst "[ID] = " & Str(Nz(Me![cboPatientLookup], 0))

If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Me.Requery

End Sub

The SQL for the combo box is below.



SELECT tblPatientDemographics.ID, tblPatientDemographics.LastName,
tblPatientDemographics.FirstName, tblPatientDemographics.MI,
tblGeneration.Generation


FROM tblGeneration RIGHT JOIN tblPatientDemographics ON
tblGeneration.GenerationId = tblPatientDemographics.Generation


WHERE (((tblPatientDemographics.LastName) Like
[Forms]![frmPtDemographics]![txtBravo]) AND
((tblPatientDemographics.Company)=[Forms]![frmCompany]![CompanySelector]))


ORDER BY tblPatientDemographics.LastName, tblPatientDemographics.FirstName,
tblPatientDemographics.MI;


TIA for the help!
Steve
 

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