List form not linking to detail form

EHS

Registered User.
Local time
Today, 11:01
Joined
Jun 23, 2011
Messages
22
Hi there
I have a form that lists people. Each field has a click event that opens a people detail form using docmd.openform "PeopleDetail", , ,"str(PeopleCode = " & str(Form!PeopleCode). The detail form opens but always displays the first people record. PeopleCode is an AutoNumber, hence the str(). All tables are linked. Can anyone help? I've used this technique in other forms and it works (even in the same database).
Thanks
 
Thanks for that vbaInet. I tried "Str(PeopleCode) = '" & Str(Me.PeopleCode)", but I got the same result. If I don't use str() I get the error message 'Data type mismatch'.
 
The correct syntax is clearly explained in the link provided. Note that it doesn't use Str() and it explains what to use to wrap your criteria if it is Text or Date. I would advise you re-read that link.
 
Thanks again. I have read the link properly this time, and used 'DoCmd.OpenForm "People Details", , , "PeopleCode = " & Me.PeopleCode'. I didn't get the Data type mismatch error, but I didn't get the required record either. The record displayed was the (yet again) first record.
 
If you open the form on its own, does it display ALL records?
 
If I open the detail form on it's own, it does display all records.
 
I really don't want to start downloading two db's. Can you consolidate them.
 
Your main problem was you had code in the Open event which was "dirtying" your form. I also made some changes too.

See attached.
 

Attachments

Thank you very much. That has been a great help
 

Users who are viewing this thread

Back
Top Bottom