473,394 Members | 1,916 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.

Search command button causing Error 2501

I am brand new to VBA - so if this is a brain-donor question...sorry!!

I have a search button on my switchboard with two fields next to it - Status and Technician.

I can search for both fields and it brings up my form.
I can search for just Status and it brings up my form.

But if I attempt to search by just Technician (stEmpID) it brings back a Run-Time Error 2501 The OpenForm was canceled.

Can someone see something I don't here?

Dim stEmpID As String
Dim iStatusID As Long
Dim stDocName As String
Dim stLinkCriteria As String
Dim stMsg As String


stEmpID = Nz(Me.cmbSupportTechforFindATicket, "")
iStatusID = Nz(Me.cmbTicketStatusforFindATicket, 0)

If ((stEmpID = "") And (iStatusID = 0)) Then
stMsg = "You must select either a Technician or a Status to use this search."
MsgBox stMsg
Exit Sub

Else
stDocName = "frmTicketSearchBYStatusOrTech"

If Not ((stEmpID = "") Or (iStatusID = 0)) Then
stLinkCriteria = "((TicketStatusID =" & iStatusID & ") AND (EmployeeID=""" & stEmpID & """))"""

ElseIf iStatusID = 0 Then
stLinkCriteria = "EmployeeID = " & stEmpID

ElseIf stEmpID = "" Then
stLinkCriteria = "TicketStatusID = " & iStatusID

End If

DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub
Jul 2 '07 #1
1 1919
un, nevermind. realized I was treated it as a number instead of string. Got it. :)
Jul 2 '07 #2

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

Similar topics

3
by: Nathan Sokalski | last post by:
I want to create a procedure in ASP.NET to run the "SET DEFINE OFF" command in an Oracle database. I tried the following: Public Shared Sub SetDefineOff() Dim myconnection As New...
5
by: DC Fan | last post by:
Hi all... Been a while since had a question here, but I can not find a single thing about this in the group or even on the whole web! My Access XP application is running some stored queries and...
1
by: Bob Dydd | last post by:
Hi everyone It's me again. I have an access 2000 database with 12 landscape reports which sometimes have to be FAXED and other times printed, so I have written the following code and put it...
6
by: San | last post by:
Hey, I need to create a form with several text boxes in which users type in key words, press a command button on the form and it opens a matching record. Thanking you in advance.
12
by: ljungers | last post by:
I'm on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run....
1
by: Chris | last post by:
I need a search form to perform. I have a Form and a subform. The subform is based off a query and the main form is unbound. The query runs perfect, however, I have a command button in the main...
3
by: razjafry | last post by:
Hi, I am trying to create a combo box to search record on the base of ID but it gives runtime error message 2501 "the openform action was cancelled" all the times. I posted this question before but...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: Mark112 | last post by:
Hi I am attempting to restore the search feature that was created by an external company using the indexing service for our intranet. the intranet is located locally at each of our offices. The...
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
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
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...
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.