473,788 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.OpenForm and stLinkCriteria problem

2 New Member
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 12875
Lysander
344 Recognized Expert Contributor
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code:

Private Sub Knop22_Click()
On Error GoTo Err_Knop22_Clic k

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ALAHistorieEdi t"

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

Exit_Knop22_Cli ck:
Exit Sub

Err_Knop22_Clic k:
MsgBox Err.Description
MsgBox Err.Number
Resume Exit_Knop22_Cli ck

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,578 Recognized Expert Moderator MVP
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
6878
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: Run-Time Error 2501 The OpenForm action was cancelled.
2
3307
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 is that if I am updating any information on the current record, and then open one of the other forms, the new form will not show the updated information. I realize that a simple macro solves this problem by basically closing the first form,...
6
4200
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 box if you want to add a new company. when you double click it brings up the new company form so you can enter the rest of the information besides just the name there. This all works. Here's what I want:
3
4520
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 the Search button, a query is run to search the Person table for a match. This produces a recordset (I am using ADO). If the RecordCount is zero, they get a No Match message. If the RecordCount is 1, a DoCmd.OpenForm is performed to open the...
15
3898
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 completing its work formB issues docmd.close ,Me docmd.openform "formA"
2
6865
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 Dim srce As String, fstnme As String, lstnme As String, bidnum As String srce = Me.Source_Control If Not IsNull(Me.Text18) Then
1
5002
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 blank form to allow me to add a new record. Problem is, every time I run the method, it opens up the first record in the database, rather than give me a new emtpy record. Please help!!!! I'm using: DoCmd.OpenForm "frmComm", acNormal, , ,...
1
2031
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 list box. I have a command button which I want to use to open another form on that record. At the moment it opens the other form but only to the first record. The other form has its recordset set to the same table as what the list box displays...
1
2718
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 database A, when "frmDownload" loaded, it does successfully create "fsubAdmmission" object and i am able to assign "fsubAdmmission.form.recordsource". Once i link my application to database B, when "frmDownload" loaded, it failed to assign...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10175
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.