Going to wrong record

  • Thread starter Thread starter dbl
  • Start date Start date
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
 
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]
 
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]
 
Back
Top