Opening to correct record

Brad108

Registered User.
Local time
Today, 11:05
Joined
Jan 26, 2007
Messages
28
Hi

I have this code set up in order to close one form and open another form, at the correct record:

Private Sub FirstName_DblClick(Cancel As Integer)
Dim stlinkcriteria As String
Dim stdocname As String
stlinkcriteria = "[ContactID]=" & Me![ContactID]
stdocname = "frmContacts"
DoCmd.OpenForm stdocname, , , stlinkcriteria
End Sub

However, when I run it it can't find the ContactID field on the form, even though it is there and is populated.

Anyone know why this is?

Thanks

Brad
 
Has Me![ContactID] been saved? Try putting:
If Me.Dirty then Me.Dirty = False
before opening the next form and see if that fixes the problem.
 
Hi

It still does the same, unfortunately.

I forgot to say that the ContactID field on the form is being populated via another table via this code:

Private Sub Form_Current()
[Forms]![frmCompany]![ContactID] = [Forms]![frmCompany]![tblContacts subform].Form![ContactID]
End Sub
 
I'll bet it is a text field. Try:
stlinkcriteria = "[ContactID]= '" & Me![ContactID] & "'"
 

Users who are viewing this thread

Back
Top Bottom