By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 2,091 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

DoCmd.OpenForm and stLinkCriteria problem

P: 2
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Knop22_Click()
  2. On Error GoTo Err_Knop22_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "ALAHistorieEdit"
  8.  
  9.     stLinkCriteria = "[ALAHistorie]![Barcode]= " & Me![Barcode] & " And  _
  10.                            [ALAHistorie]![Teller]= " & Me![Teller]
  11.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_Knop22_Click:
  14.     Exit Sub
  15.  
  16. Err_Knop22_Click:
  17.     MsgBox Err.Description
  18.     MsgBox Err.Number
  19.     Resume Exit_Knop22_Click
  20.  
  21. End Sub
When i debug, the stLinkCriteria contains (for example) :
"[ALAHistorie]![Barcode]= 12345 And [ALAHistorie]![Teller]= 2"

Barcode and Teller (autonumberd counter) are numeric and the record does exist. But i keep getting error 2501, action openform cancelled. With only Barcode as criteria in stLinkCriteria the action succeeds but (logically) only with the first record with that Barcode.

What am i doing wrong with the criteria for that seems to be the problem?

Tanx,
Mark
Jun 11 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 344
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code:

Private Sub Knop22_Click()
On Error GoTo Err_Knop22_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ALAHistorieEdit"

stLinkCriteria = "[ALAHistorie]![Barcode]= " & Me![Barcode] & " And _
[ALAHistorie]![Teller]= " & Me![Teller]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Knop22_Click:
Exit Sub

Err_Knop22_Click:
MsgBox Err.Description
MsgBox Err.Number
Resume Exit_Knop22_Click

End Sub


When i debug, the stLinkCriteria contains (for example) :
"[ALAHistorie]![Barcode]= 12345 And [ALAHistorie]![Teller]= 2"

Barcode and Teller (autonumberd counter) are numeric and the record does exist. But i keep getting error 2501, action openform cancelled. With only Barcode as criteria in stLinkCriteria the action succeeds but (logically) only with the first record with that Barcode.

What am i doing wrong with the criteria for that seems to be the problem?

Tanx,
Mark
What is the record source for the form ALAHistorieEdit?
Jun 11 '07 #2

NeoPa
Expert Mod 15k+
P: 31,276
Your continuation on line 9 is not a contiuation because it falls within your literal string.
Try :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Knop22_Click()
  2. On Error GoTo Err_Knop22_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "ALAHistorieEdit"
  8.  
  9.     stLinkCriteria = "[ALAHistorie]![Barcode]=" & Me![Barcode] & " And  " & _
  10.                      "[ALAHistorie]![Teller]=" & Me![Teller]
  11.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_Knop22_Click:
  14.     Exit Sub
  15.  
  16. Err_Knop22_Click:
  17.     MsgBox Err.Description
  18.     MsgBox Err.Number
  19.     Resume Exit_Knop22_Click
  20.  
  21. End Sub
Jun 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.