473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DoCmd.OpenForm and stLinkCriteria problem

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
2 12824
Lysander
344 Expert 100+
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
32,556 Expert Mod 16PB
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

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

Similar topics

2
by: Stuart Clark | last post by:
Hi, I have the following lines of code: stLinkCriteria = " BETWEEN " & & " AND " & DoCmd.OpenForm stDocName, , , stLinkCriteria Every time I try and run this I get the following error:...
2
by: chanchito_cojones | last post by:
hi there, I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up other forms. The problem I am having...
6
by: beowulfs | last post by:
Here's what I've got: I've got a form with combo boxes. you can select already existing company names or type in new ones. if you type in a new one, it prompts you to double click the combo...
3
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
2
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data...
1
by: RAG2007 | last post by:
Hi all, Have a question I can't get around. I've done this before and for some reason can't get it to work this time. I'm opening a form through docmd.openform, and trying to get it to open an...
1
by: rdsandy | last post by:
Hi, I am using Access 2003. I have a list box on a form which has 6 columns in it, with data taken from a table. I have an unbound text box which holds the ID number for the selected item in the...
1
by: silen | last post by:
i am using Access2000. Currently i had a main form call "frmDownload" and sub form "fsubAdmmission". Under the fsubAdmmission, i do have another sub form "fsubHospital". Once i link my application to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.