Help with search form

kate10123

Registered User.
Local time
Today, 00:54
Joined
Jul 31, 2008
Messages
185
Hi there,

In my search form, I can type in a surname or firstname of a student and then any matches appear in a listbox. I have a double-click method which should allow me to double-click on a listbox item and that unique record opens. This works sometimes but in situations where there are two entries with the same surname, double-clicking on a particular entry makes no difference as the FindFirst method brings up the first record it finds.

In the attached search form I have a line of code that I think is causing this problem.

RecordsetClone.FindFirst

Any ideas on a way around this?
 

Attachments

Lose the brackets:

DoCmd.OpenForm "frm_student", , , "[StudentID] = " & Me![QuickSearch].Column(2)
 
Thanks for replying.

I have tried removing the brackets and then performing the search. The results appear but when I click on any of the results I get the error message '[studentid] cannot be found'. Then the form opens with a blank record and not the one I clicked.
 
I think I took the code out of the update event of the listbox and used that in the click event, and it worked fine. No need to have the code in both places.
 
Do you mean take out all of the code from the after update section?
 
IIRC, that's what I did (not on the same PC today). As I recall, you had similar code running in both events, so I deleted the after update code and modified the click code as noted.
 
Hi guys,

I still haven't managed to fix this form. Has anyone got any ideas?

In the original search form, I had a search filter on the surname but for uniqueness it needs to be student ID.

Thanks for any replies.
 
If it's changed, post the new version and one of us will fix it.
 
I only have A2k here, so I'll look at it this evening.
 
Well, once again I've gotten rid of the code in the after update event of the listbox and changed the code in the click event to the same thing I posted before:

DoCmd.OpenForm "frm_student", , , "[StudentID] = " & QuickSearch.Column(2)

And it works as I would expect. When I click on a record in the listbox that record opens in the detail form. I don't see the point to the after update code.
 
Sorry I couldn't work out how the search would work without the findfirst code so this was the confusion.

Thanks alot for your help and patience :)
 

Users who are viewing this thread

Back
Top Bottom