Query Criteria to limit results to existing records

TKT_BEER

New Member
Joined
Dec 22, 2003
Messages
38
Hi everybody, hope your new year was a good one! here it goes..

A LITTLE HISTORY
I have a SELECT QUERY that is attached to a form, every time you open the form a ENTER PARAMETER value box appears, Query is going after an AUTONUM so when you enter a REQ number all the information related to this number will populate.

BUT everytime that I enter a number that doesnt exist, the QUERY shows an EMPTY form.

Is there a way to limit the query to the existing records so that if you enter a REQ that is nonexisten (EX. you have reqs 1 thourgh 10 and you enter req. #11) a MSG box appears telling me that the req does not exist or is not available? any help is appreciated!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Here's how I'd solve the problem:

1) Create a form that resembles a windows dialog box to ask for the req. number.
2) In the On Open event of your main form, open the dialog box.
3) In the click event for the OK button on your dialog box, open a recordset for the query (select reqnum from requisitions).
4) If the recordcount property of the recordset is zero, display the "Req. does not exist." message, otherwise close the dialog box, make the main form active and go to the appropriate record.

Good luck!
 
Upvote 0
it's opening the ENTER PARAMETER VALUE MSG BOX before opening the form that I did... isnt there a way to do this in the SQL view for this query?
 
Upvote 0

Forum statistics

Threads
1,221,607
Messages
6,160,787
Members
451,671
Latest member
kkeller10

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top