Going to wrong record

D

dbl

Hi I have the following code in my form Incident Data Entry:

Dim Docname As String
Dim LinkCriteria As String

Me.Form.AllowEdits = True
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
Me.Form.AllowEdits = False
Docname = "Confirmation of Events"
LinkCriteria = "[CustomerID] = Forms![Incident Data Entry]![Field143]"
DoCmd.OpenForm Docname, , , LinkCriteria

9 times out of 10 it opens the correct record in form Confirmation of Events
but sometimes in opens the form in the wrong record which is causing major
problems
any help would be very much appreciated.

Thanks Bob
 
S

Stuart McCall

dbl said:
Hi I have the following code in my form Incident Data Entry:

Dim Docname As String
Dim LinkCriteria As String

Me.Form.AllowEdits = True
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
Me.Form.AllowEdits = False
Docname = "Confirmation of Events"
LinkCriteria = "[CustomerID] = Forms![Incident Data Entry]![Field143]"
DoCmd.OpenForm Docname, , , LinkCriteria

9 times out of 10 it opens the correct record in form Confirmation of
Events but sometimes in opens the form in the wrong record which is
causing major problems
any help would be very much appreciated.

Thanks Bob

Your LinkCriteria is incorrectly assigned. It should read:

LinkCriteria = "[CustomerID] = " & Forms![Incident Data Entry]![Field143]
 
D

dbl

Will give that a try.

Thanks Bob

Stuart McCall said:
dbl said:
Hi I have the following code in my form Incident Data Entry:

Dim Docname As String
Dim LinkCriteria As String

Me.Form.AllowEdits = True
DoCmd.DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD, , A_MENU_VER20
Me.Form.AllowEdits = False
Docname = "Confirmation of Events"
LinkCriteria = "[CustomerID] = Forms![Incident Data Entry]![Field143]"
DoCmd.OpenForm Docname, , , LinkCriteria

9 times out of 10 it opens the correct record in form Confirmation of
Events but sometimes in opens the form in the wrong record which is
causing major problems
any help would be very much appreciated.

Thanks Bob

Your LinkCriteria is incorrectly assigned. It should read:

LinkCriteria = "[CustomerID] = " & Forms![Incident Data Entry]![Field143]
 

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