473,398 Members | 2,188 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,398 software developers and data experts.

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.SetWarnings False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarnings 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 1664
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.Setwarnings False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarnings 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!
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.Setwarnings False
DoCmd.RunSQL (MySQL)
DoCmd.SetWarnings 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
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: ...
2
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...
3
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:...
2
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...
2
by: Roger | last post by:
Anyone know how to pass a parameter to a query via a report in Access 2003?
2
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...
1
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...
4
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...
5
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...
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
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
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
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...
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.