PDA

View Full Version : Comparing Value



noobiegal
04-16-2006, 07:33 AM
Hi All, Im a newbie in Access/VBA and would like some help.

I got 3 tables called A,B,C. All with 3 Columns (Level, Min Dist, Max Dist).

I wanna make a form
The controls which i wanna haf are as follows:
- drop down list that allows me to choose A, B or C.
- 2 txtbox which allows user to input a Level and Distance in it. After which, they press a button which will take the value they input and compare to the value in the table. It will look up the level from the table and then compare whether the distance is within the Min Dist and Max Dist. If yes, show a msgbox, if no, show another msgbox.

The problem now is that i got no idea how to code "look up the level from the table and then compare whether the distance is within the Min Dist and Max Dist. If yes, show a msgbox, if no, show another msgbox." into the to the onclick of the button.

Your help is much appreciated.

OBP
04-17-2006, 01:40 AM
noobiegal, it would probably make sense to have an option group to select the Table. The check for level and within the Min Max length can be tested for in a query.
Is this some kind of "course work"?
How many records are there in each table?

noobiegal
04-17-2006, 07:23 AM
Selecting the table is not an issue.. but i wanna know how to make it go the correct level and check for min and max.. heres an example

Level...... Min Dist ...... Max Dist

10..............6.................15

20..............3.................20
30..............7.................30
40..............10...............35

The form will have 2 txtbox for me to input Level and Dist. If i input 30 and 25, it go to the 30 row and compare 25 with the min and max. Then show it as within dist.

So i think i should add the code into the onclick of a button? But what should i add?

Its not an course work but its just to help improve my workplace processes.. about 16 records in each tables

OBP
04-17-2006, 08:35 AM
noobiegal, the attached database uses the minimum of more advanced VBA it is in the "After Update Event" of the Option Group.
In Form1, based on the table selected in the "option group" it will open one of 3 forms in hidden mode. Clicking table 1 opens table 1, clicking table 2 opens table 2 etc.
The queries for each of the forms have criteria rows which "filter" the data according to your entries in the Level and Distance fields.
The VBA just checks the value in the first record, if it is greater than zero there is at least one matching record and it tells you. If the value is zero there are no matches and it tells you.

I am sure that the more advanced VB programmers on here can do the same for you using SQL and Recordsets, but at least this works.