473,395 Members | 1,554 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,395 software developers and data experts.

VBA, Openform error in where statement

Hello all, I am haveing a problem with the openform method.

I want to open a form with the where method but It gives me an error

Run-Time error "2501"
The Openform action was canceled

You used a method of the DoCmd object to carry out an action in Visual basic, but then clicked cancel in a dialog box

Can you please help me figure out what is wrong with my code
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frm_Reporting_Defect_History", , , "dbo_GS_LMS_DEFECT_SHEETS.CUSTOMER_NAME = '" & Forms!frm_Main.cbCustomer & _
  2.                                                     "' And dbo_GS_LMS_DEFECT_SHEETS.WO_NUMBER = '" & Forms!frm_Code_Repeat_Shoppings.[PostWorkOrderNum] & _
  3.                                                     "' And dbo_GS_LMS_DEFECT_SHEETS.LOCOMOTIVE_ID = '" & _
  4.                                                     Forms!frm_Code_Repeat_Shoppings.[tbLocoID] & "'"
Dec 6 '09 #1
1 1950
MikeTheBike
639 Expert 512MB
Hi

I think I would rewrite the open statment like this
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frm_Reporting_Defect_History", , , "CUSTOMER_NAME = '" & Forms!frm_Main.cbCustomer & "'  _ 
  2.                                                      And WO_NUMBER = '" & Forms!frm_Code_Repeat_Shoppings.[PostWorkOrderNum] & "'_ 
  3.                                                      And LOCOMOTIVE_ID = '" & _ 
  4.                                                     Forms!frm_Code_Repeat_Shoppings.[tbLocoID] & "'" 
The reason for this, and the assumption made are as follows:-

1) The left hand side of the boolean operator (= in this case) of the 'WHERE' clause should refer only to the field available in the 'frm_Reporting_Defect_History' form.

2) I assume that CUSTOMER_NAME, WO_NUMBER and LOCOMOTIVE_ID are all fields in the Record Source for 'frm_Reporting_Defect_History' form.

3) It is also assumed that all the forms refered to on the right hans side of the boolean operator are open!

4) Last but not least, I assume that WO_NUMBER and LOCOMOTIVE_ID are text fields !?

Hope this is of some help, and may give some clues as to the problem (as I have no real idea as to exaclty what the Error is specificaly caused by).


MTB
Dec 7 '09 #2

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

Similar topics

1
by: Nothing | last post by:
I have a form that the user types in a last name to search for then clicks a search button. Based on the information I want to open the form using the SQL Where statement that will pattern match...
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...
3
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around...
2
by: jeffrod444 | last post by:
Hi, I've been having problems getting my forms to work correctly. If seen other threads addressing this issue, however, these are not working for me. The short of my problem is this. I am trying to...
4
by: SUNNY | last post by:
I need help I am trying to Open a FORM_A in a Single Form View for a selected record on FORM_B which is in Datasheet View. End user double clicks on a FORM_B (DataSheet View) to open FORM_A in...
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...
3
by: Mike Charney | last post by:
I am having trouble with the where clause in an openreport statement in an Access Data Project. I am using MS-Access 2003 with SQL Svr 2000. The line I am using is: DoCmd.OpenReport...
7
by: rik | last post by:
I am trying to build an Access 2002/2003 database application that I would like to offer to other writers so they can track submissions. Just trying to make a helpful tool for writers, poets, or...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.