Below is what I have. I need this to determine if a meter reading
(always growing number) taken today is mistakenly entered as a smaller
number than the reading taken the day before. I originally had this
procedure begin on lostfocus, but that created errors when moving
through records without leaving the field. Now I am not getting the
error message at all.
Private Sub BOILER_1_GAS_ME TER_OnExit()
Dim rs As DAO.Recordset
Dim lngCompare As Long
Dim strmsg As String
Dim Msg, Style, Title, Response
Set rs = Me.RecordsetClo ne
Msg = "Please enter a value greater " & vbCrLf & "than previous value
of " & lngCompare & "." ' Define message.
Style = vbOKOnly ' Define buttons.
Title = "Invalid Entry" ' Define title.
With rs
.MoveNext
lngCompare = ![BOILER 1 GAS METER]
End With
If Me.BOILER_1_GAS _METER < lngCompare Then
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
Cancel = True
End If
End If
rs.Close
Set rs = Nothing
End Sub 7 2296
So...if you're not getting an error, what is the difficulty you need
help with?
In testing the system, I entered data that should have produced the
message box.
You might try moving your code into the AfterUpdate event of your
textbox instead of OnExit.
Is the value that's being returned in your recordset correct? You can
use the Immediate window in the VBE to find out if you put a breakpoint
in your code near the With rs line.
"GoalieGW" <Go******@ptd.n et> wrote In testing the system, I entered data that should have produced the message box.
The appropriate event for validation tests is the BeforeUpdate event. If you
find a validation error, cancel the event by setting the Cancel argument to
True before exiting.
Larry Linson
Microsoft Access MVP
if you stuff the previous value into a variable, it's easy. Create a
parameterized top values query.
SELECT TOP 1 VALUES...
FROM
WHERE MeterID=Forms!M yForm!MeterID
ORDER BY DATE DESCENDING...
and then when you open the recordset, assign that value to a variable,
say something like lngLastReading.
If me.CurrentReadi ng<lngLastReadi ng Then
msgbox "Meter readings can only go UP!",vbokonly
me.currentreadi ng.setfocus
me.currentreadi ng=""
end if
I am getting the following error.
The expression Before Update you entreed as the event property setting
produced the following error: Procedure declaration does not match
descriptin of event or procedure having the same name.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluation the function, event, or macro.
Here is the code again.
Private Sub BOILER_1_GAS_ME TER_beforeUpdat e()
Dim rs As DAO.Recordset
Dim lngCompare As Long
Dim strmsg As String
Dim Msg, Style, Title, Response
Msg = "Please enter a value greater " & vbCrLf & "than previous value
of " & lngCompare & "." ' Define message.
Style = vbOKOnly ' Define buttons.
Title = "Invalid Entry" ' Define title.
Set rs = Me.Current
With rs
.MoveNext
lngCompare = ![BOILER 1 GAS METER]
End With
If Me.BOILER_1_GAS _METER < lngCompare Then
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
Cancel = True
Me.BOILER_1_GAS _METER.SetFocus
Me.BOILER_1_GAS _METER = ""
End If
End If
rs.Close
Set rs = Nothing
End Sub
an error in naming?
BOILER_1_GAS_ME TER is the name of this sub - is this the name of a control on
a form (code behind form?) and the name of the field in the recordset? If
that does not create a problem in this situatioon then nevermind ... ;-)
Also it looks like you forgot to put the "_" where the spaces are in your
code?
lngCompare = ![BOILER 1 GAS METER]
Hope this is of some help,
Roger
GoalieGW wrote: I am getting the following error. The expression Before Update you entreed as the event property setting produced the following error: Procedure declaration does not match descriptin of event or procedure having the same name.
*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]. *There may have been an error evaluation the function, event, or macro.
Here is the code again.
Private Sub BOILER_1_GAS_ME TER_beforeUpdat e() Dim rs As DAO.Recordset Dim lngCompare As Long Dim strmsg As String Dim Msg, Style, Title, Response Msg = "Please enter a value greater " & vbCrLf & "than previous value of " & lngCompare & "." ' Define message. Style = vbOKOnly ' Define buttons. Title = "Invalid Entry" ' Define title. Set rs = Me.Current With rs .MoveNext lngCompare = ![BOILER 1 GAS METER] End With
If Me.BOILER_1_GAS _METER < lngCompare Then Response = MsgBox(Msg, Style, Title) If Response = vbOK Then Cancel = True Me.BOILER_1_GAS _METER.SetFocus Me.BOILER_1_GAS _METER = "" End If End If rs.Close Set rs = Nothing End Sub
--
Message posted via AccessMonster.c om http://www.accessmonster.com/Uwe/For...ccess/200512/1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Moore |
last post by:
One of the things I really dislike about Unittest (compared, say, to a
number of adhoc testing tricks I've used in the past, and to Perl's
"standard" testing framework) is that the testcase-as-a-class model
tends to imply a relatively high granularity in testing.
A good example of this comes from "Dive Into Python"...
|
by: chuck amadi |
last post by:
By the way list is there a better way than using the readlines() to
> > >parse the mail data into a file , because Im using
> > >email.message_from_file it returns
> > >all the data i.e reads one entire line from the file , headers as
well
> > >as just the desired body messages .
> > >
> > >fp = file("/home/chuck/pythonScript/testbox")
> >...
|
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is difficult to know what
is going on.
One of these Order Forms you can see here...
http://www.cardman.co.uk/orderform.php3
|
by: ranjeet |
last post by:
Dear All !!
I have a code which is giving the desired reults.
Now I am making the DLL of the code in VC6 and then run this DLL and
I am able to get the same Result what I want.
Now when I make a project in .net of this code, then also I get the
same result.
|
by: Neo The One |
last post by:
I think C# is forcing us to write more code by enforcing a rule that can be
summarized as 'A local variable must be assgined *explicitly* before reading
its value.'
If you are interested in what I mean, please look at this feedback my me:
...
| |
by: Trickynick1001 |
last post by:
Hi, a newbie here. I don't have a real firm grasp on the idea of
Javascript, as I'm used to programming in Qbasic and C. I'm not used
to OOP. Anyway, I really don't have any idea what the problem is with
this code, it just simply won't work properly. Some of the functions
aren't done, but the main one gives me a Not a Number message in the...
|
by: gw7rib |
last post by:
I've been bitten twice now by the same bug, and so I thought I would
draw it to people's attention to try to save others the problems I've
had. The bug arises when you copy code from a destructor to use
elsewhere.
For example, suppose you have a class Note. This class stores some
text, as a linked list of lines of text. The destructor runs...
|
by: David Golightly |
last post by:
This is just a quick poll for all you web devs out there: What
browsers do you test on/are concerned about compatibility with?
Obviously, you're going to test on current-generation browsers such as
IE6, IE7, Firefox 1.5/2, Opera 8/9, Safari 2, etc.
How old must a browser be before you stop worrying about it? Anybody
here still test on...
|
by: Steve |
last post by:
Can someone help me with this code - I'm trying to retrieve updated
product information by pulling 3 fields and inserting values into my
MYSQL db. In my code below I'm getting the page but I can't get the
date inserted into the DB what am I doing wrong.
Second Can I suppress output to screen. I'm planning on running this
in cron if I'm...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |