473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter type append query dialog box - how to abort smoothly?

MLH
I have the following code in an Access 97 procedure:

MySQL = "INSERT INTO tblVehicleNames (VehicleMake) SELECT [Enter the
make] AS [NewMakenModel];"
DoCmd.SetWarnin gs False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarnin gs True

When it runs, a dialog box instructing me to "Enter the make". It
is expecting me to type in something like "Chevy Caprice". The dialog
box has 2 buttons: OK and Cancel. If I enter nothing at all and click
"OK", nothing happens. No record is appended to tblVehicleNames and
no error occurs. However, if I click "Cancel", error #2766 occurs. Why
does "Cancel" result in an error when "OK" does not?
Nov 13 '05 #1
2 1674
Use an inputbox to ask them the make before you build your sql string.
Like this;

Dim strRetVal as String, mySQL as String

strRetVal = Inputbox("Enter the make")

If Len(strRetVal) > 0 Then 'only proceed if they enter something
mySQL = "INSERT INTO tblVehicleNames (VehicleMake) VALUES ('" &
strRetVal & "')"
DoCmd.Setwarnin gs False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarnin gs True
Else ' If you want, you can tell them what they did wrong
msgbox "Must enter a vehicle make"
End If

This code is not pretty but it gives you the general idea.

Nov 13 '05 #2
MLH
Good suggestion, Wolf. Many thx!
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxx
Use an inputbox to ask them the make before you build your sql string.
Like this;

Dim strRetVal as String, mySQL as String

strRetVal = Inputbox("Enter the make")

If Len(strRetVal) > 0 Then 'only proceed if they enter something
mySQL = "INSERT INTO tblVehicleNames (VehicleMake) VALUES ('" &
strRetVal & "')"
DoCmd.Setwarni ngs False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarni ngs True
Else ' If you want, you can tell them what they did wrong
msgbox "Must enter a vehicle make"
End If

This code is not pretty but it gives you the general idea.


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5821
by: The Plankmeister | last post by:
Hi... I have a query which I'm accessing through PHP as a stored procedure. However, I need to be able not to pass a couple of parameters in certain situations. When I do this, I get an error: Parameter has no default value. But it works fine in Access when I run the query from there and just hit
2
2188
by: RBohannon | last post by:
I have a report with most fields populated by a query. However, some of the fields are variable in such a way that their values cannot be queried from a table. At present the values for these fields are being entered by the user as parameter values when the query is run. But there are four fields which need to be entered, and the pop-up...
3
1943
by: dnl | last post by:
I have a parameter query that I would like to simplify so that I wouldn't need to use wildcards when entering in partial data. The following line is in the criteria field when designing the query: Like Running the query brings up the dialog box to enter the parameter. If the name I am looking for is Smith, I can type "smi*" to do a...
2
2911
by: mounilkadakia | last post by:
I have a CrystalReportViewer(crv) on my form. I also have a dataset (dtsReportData) populated with the required data and i have a ReportDocument (rdReport) object. The data source for the crystal report (CR 11) is a stored procedure. This is what i am doing:- rdReport.Load("ReportLocation"); //ReportLocation is the file path....
2
6367
by: Roger | last post by:
Anyone know how to pass a parameter to a query via a report in Access 2003?
2
3257
by: billtubbs | last post by:
Hi I am getting the common problem of the "Enter Parameter Value" dialog box, which pops up every time I execute a query. I built the query using the Expression Builder in Access. If any of my expressions reference another column in the same query, it causes the dialog box to appear for each parameter before displaying the query output, even...
1
5054
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately began getting the "Enter Parameter Value" dialog and it was asking for the query by its name "sel_report_data" whenever I tried to run or preview the...
4
1314
by: Giampaolo Rodola' | last post by:
Hi, for an FTP server I wrote I'd need to group the FTP commands in one table that defines the command itself, the syntax string, required permission, whether it requires authorization, whether it takes argument and whether there's a need to validate the path from the argument. The more obvious way I found to do that is something like this:...
5
5300
by: Trevisc | last post by:
Happy Thursday Everyone, I am trying to create a parameter that is one long varchar but that will be used in a SQL statement IN function: //string queryString = GetCurrentTitles(); //Below is for Test string queryString = "45322,32222,33344,55555"; dataset catalogDS = new dataset();
0
7665
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...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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...
1
7642
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...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
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...
1
2082
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
0
924
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...

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.