Open Form to specific record - NOT WORKING

jsdba

Registered User.
Local time
Yesterday, 21:06
Joined
Jun 25, 2014
Messages
165
I have DoCmd.OpenForm hundreds of places in my application but for some reason it doesn't not work properly one of my most critical forms.

Code:
DoCmd.OpenForm "frmForm", acNormal, , "ID=" & Me.ID
The above does not open to the record i.e. "ID", form opens to a new record. I have some OnCurrent code that does some evaluations and ID = null. So i know for some reason ID is not being passed to the form filter.

Code:
DoCmd.OpenForm "frmForm", acNormal
DoCmd.OpenForm "frmForm", acNormal, , "ID=" & Me.ID
If i do the above, essentially opening the form without specifying which record THEN anther DoCmd.OpenForm with where clause it opens to the record but also creates another empty record...i assume on the first DoCmd.OpenForm.

This is the only time i've seen something like this.
 
My guess is the default of the form view is set to Form Add (thus new record) so you will have to specify Edit.

docmd.OpenForm "frmName",acNormal,,"id = " & me.id,acFormEdit

acFormEdit did the trick. nice.
 
Glad to hear because after rereading the second part of your post I did not think that was what you were describing so I deleted my post. It sounded as if it was opening in edit view and then moving to a new record. That would only happen if there was code in opened form to do that. Add mode opens to a single record which looks different than edit mode with all the records and then moving to the new record.
 

Users who are viewing this thread

Back
Top Bottom