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 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
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 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 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.
Thanks for your replies, especially Salad that code works perfectly. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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....
|
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
|
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....
|
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...
|
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,...
| |
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: 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,...
|
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...
|
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...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |