473,499 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help Checking Values in one table against two min max values in another

Hello

Have searched the group for a solution to the following problem without
success:

Table 1 has Ref No (No Duplicates) & Min Max Value Fields
ie Ref No 1 Min 1 Max 10
Ref No 2 Min 11 Max 20 etc

Table 2 is linked by Ref No (Allows Duplicates) & Recorded Value
Ie 1) Ref No 1 Recorded Value 5
2)Ref No 1 Recorded Value 8
3)Ref No 2 Recorded Value 19
4)Ref No 2 Recorded Value 7 etc

The idea is the Recorded Value is accepted for 1,2,& 3 however an
invalid entry pop up disallows entry of 4 as it is outside the Value.
Unfortunately, what happens in this case is that 3 throws up the error
as the code used always compares against the first min max Values
recorded, which means 4 is accepted

The Code Used is as follows:

Private Sub Nom_Burst_Pressure_BeforeUpdate()
Dim varUP, varLow, varAct As Variant

varUP = DLookup("[Max]", "Table 1", "")

varLow = DLookup("[Min]", "Table 1", "")

varAct = Me.Recorded_Value
If varAct > varUP Then
MsgBox "This number is Above maximum value"
DoCmd.CancelEvent
ElseIf varAct < varLow Then
MsgBox "This number is Below minimum value"
DoCmd.CancelEvent

End If

End Sub

How do I compare Recorded Value in table 2 for each Ref No against min
max values in table 2 where the Ref No is the same

Please Help

Nov 13 '05 #1
5 2311
ke********@hotmail.com wrote:
Hello

Have searched the group for a solution to the following problem without
success:

Table 1 has Ref No (No Duplicates) & Min Max Value Fields
ie Ref No 1 Min 1 Max 10
Ref No 2 Min 11 Max 20 etc

Table 2 is linked by Ref No (Allows Duplicates) & Recorded Value
Ie 1) Ref No 1 Recorded Value 5
2)Ref No 1 Recorded Value 8
3)Ref No 2 Recorded Value 19
4)Ref No 2 Recorded Value 7 etc

The idea is the Recorded Value is accepted for 1,2,& 3 however an
invalid entry pop up disallows entry of 4 as it is outside the Value.
Unfortunately, what happens in this case is that 3 throws up the error
as the code used always compares against the first min max Values
recorded, which means 4 is accepted

The Code Used is as follows:

Private Sub Nom_Burst_Pressure_BeforeUpdate()
Dim varUP, varLow, varAct As Variant

varUP = DLookup("[Max]", "Table 1", "")

varLow = DLookup("[Min]", "Table 1", "")

varAct = Me.Recorded_Value
If varAct > varUP Then
MsgBox "This number is Above maximum value"
DoCmd.CancelEvent
ElseIf varAct < varLow Then
MsgBox "This number is Below minimum value"
DoCmd.CancelEvent

End If

End Sub

How do I compare Recorded Value in table 2 for each Ref No against min
max values in table 2 where the Ref No is the same

Please Help


This is air code.
The statement "varAct = Me.Recorded_Value", I think is incorrect.
Me.Recorded_Value is what your are testing and RefNo is what will be
returned if Recorded_Value is valid.

If isNull(Dlookup("RefNo","Table 1",Me.RecordedValue & "=> Min and " & _
RecordedValue & " =< Max") Then
msgbox "Invalid Entry", 48
Else
varAct=Dlookup("RefNo","Table 1",Me.RecordedValue & "=> Min and " & _
RecordedValue & " =< Max")
Endif

Ron

Nov 13 '05 #2
Thanks for quick reply and sorry about air code, unfortunately I am
relatively new to this. I don't quite understand what you are saying
where:
Me.Recorded Value is what i am testing.

Note:
Ref No will be duplicated and the Recorded Values vary in table 2
However once Ref No and Min Max Values are set in table 1 they remain
the same no duplicate ref nos or changes to the min max Values.
The problem is I have a moving target ie Ref No 1 from Table 1 can only
be hit by Ref No 1 from Table 1 with the Recorded Values measured
against the Min Max Values and Ref No 2 from Table 1 can only be hit by
Ref No 2 from Table 2 with the Recorded Values measured against the Min
Max Values and so on.

Unfortunately when I tried the code suggested as follows it failed to
get past the first line due to a Run time error 3035 and I remain
unsuccessful Please Help:

Private Sub P_Value_BeforeUpdate(Cancel As Integer)

Dim varAct As Variant

If IsNull(DLookup("A", "A1", Me.P_Value & "=> Min" & Me.P_Value & " =<
Max")) Then

MsgBox "Invalid Entry", 48
Else
varAct = DLookup("A", "A1", Me.P_Value & "=> Min and " & _
P_Value & " =< Max")
End If

End Sub

Nov 13 '05 #3
ke********@hotmail.com wrote:
Hello

Have searched the group for a solution to the following problem without
success:

Table 1 has Ref No (No Duplicates) & Min Max Value Fields
ie Ref No 1 Min 1 Max 10
Ref No 2 Min 11 Max 20 etc

Table 2 is linked by Ref No (Allows Duplicates) & Recorded Value
Ie 1) Ref No 1 Recorded Value 5
2)Ref No 1 Recorded Value 8
3)Ref No 2 Recorded Value 19
4)Ref No 2 Recorded Value 7 etc

The idea is the Recorded Value is accepted for 1,2,& 3 however an
invalid entry pop up disallows entry of 4 as it is outside the Value.
Unfortunately, what happens in this case is that 3 throws up the error
as the code used always compares against the first min max Values
recorded, which means 4 is accepted

The Code Used is as follows:

Private Sub Nom_Burst_Pressure_BeforeUpdate()
Dim varUP, varLow, varAct As Variant

varUP = DLookup("[Max]", "Table 1", "")

varLow = DLookup("[Min]", "Table 1", "")

varAct = Me.Recorded_Value
If varAct > varUP Then
MsgBox "This number is Above maximum value"
DoCmd.CancelEvent
ElseIf varAct < varLow Then
MsgBox "This number is Below minimum value"
DoCmd.CancelEvent

End If

End Sub

How do I compare Recorded Value in table 2 for each Ref No against min
max values in table 2 where the Ref No is the same

Please Help


I'm not so crazy about using words to define a field like Min or Max
that are really function mames. But that's your problem in deciding
whether or not to keep/use. Getting onto your problem

'first, get the min/max for the specific ref no
varUP = NZ(DLookup("[Max]", "Table 1", "[Ref No] = " & Me![Ref No]),0)
varLow = NZ(DLookup("[Min]", "Table 1", "[Ref No] = " & Me![Ref No]),0)

'set to zero in case an up/low/act is null
varAct = NZ(Me.Recorded_Value,0)
If varAct > varUP Then
MsgBox "This number is Above maximum value"
Cancel = True
Elseif varAct < varLow Then
MsgBox "This number is Below minimum value"
Cancel = True
End IF
Nov 13 '05 #4
ke********@hotmail.com wrote in
news:11**********************@g47g2000cwa.googlegr oups.com:
Hello

Have searched the group for a solution to the following
problem without success:

The Code Used is as follows:

Private Sub Nom_Burst_Pressure_BeforeUpdate()
Dim varUP, varLow, varAct As Variant

varUP = DLookup("[Max]", "Table 1", "")

varLow = DLookup("[Min]", "Table 1", "")

varAct = Me.Recorded_Value
If varAct > varUP Then
MsgBox "This number is Above maximum value"
DoCmd.CancelEvent
ElseIf varAct < varLow Then
MsgBox "This number is Below minimum value"
DoCmd.CancelEvent

End If

End Sub

How do I compare Recorded Value in table 2 for each Ref No
against min max values in table 2 where the Ref No is the same

Please Help


First let me caution you about field names that are the same as
reserved words in Access Basic, like min, max, name.....
Avoid them and avoid spaces in field names too, they can mess
you up.

Your DLookup calls are incorrect.
DLookup("[Max]", "Table 1", "") will return the first record in
your table, because you have the empty string as criteria. What
you need is to put a criterium in hteere which selects the
correct pair of limits.

DLookup("[Max]", "Table 1", "[Ref No] = " & me.[ref no]) will
give you the correct limit


--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5
Thanks for your replies, especially Salad that code works perfectly.

Nov 13 '05 #6

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

Similar topics

0
1386
by: richardkreidl | last post by:
What I'd like to do is to check the values in an element if they're greater than a certain time and if they are, then change the font color of the time. I have about 10 elements that I will check...
9
4016
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
1
1032
by: RC | last post by:
-------------------------------------------------------------------------------- All, Need ideas on how to approach this: Have to compare account numbers in one table to account numbers in...
13
1621
by: Jeff Davis | last post by:
Right now performance isn't a problem, but this question has me curious: Let's say I have a shopping cart system where there is a "products" table that contains all possible products, and an...
18
2238
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
5
3712
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
0
3227
by: Phils | last post by:
Hello guys; I i have just found the solution to my problem but would like to full understand the solution so would be great full if you could enlighten me. OUR Set-up
3
2442
by: w.m.gardella.sambeth | last post by:
Hi all, I am more or less new to Python, and currently am making my first "serious" program. The application is a Clinical History manager (for my wife) which stores its data on a sqlite database....
0
7012
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
7180
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,...
0
7392
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...
0
5479
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,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
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 ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.