473,501 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wrong result from recordset

The below code is not giving me the desired result. I am trying to
compare the same field on two seperate records. One being the current
record, the other being the day before. The code works to a degree,
but the "lngcompare" keeps resulting in 0. I am not getting the field
data from the recordset. Any thoughts?

Private Sub BOILER_1_GAS_METER_BeforeUpdate(Cancel As Integer)
Dim rs As Recordset
Dim lngcompare As Long
Dim strmsg As String
Dim msg, style, title, respose
msg = "Please enter a value greater " & vbCrLf & "than previous value
of " & lngcompare & "."
style = vbOKOnly
title = "Invalid Entry"
Set rs = Me.RecordsetClone
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 re = Nothing
End Sub

Dec 12 '05 #1
5 1517
GoalieGW <Go******@ptd.net> wrote:
: The below code is not giving me the desired result. I am trying to
: compare the same field on two seperate records. One being the current
: record, the other being the day before. The code works to a degree,
: but the "lngcompare" keeps resulting in 0. I am not getting the field
: data from the recordset. Any thoughts?

<snip>
: msg = "Please enter a value greater " & vbCrLf & "than previous value
: of " & lngcompare & "."

<snip>
: 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
msg is defined before lngcompare has gotten any value from the
recordset: inside the loop it's pure text: put msg inside or
after the
With rs loop
so that the lngcompare value can be updated.
--thelma

Dec 12 '05 #2
Thank you, that helped. Now I need the code to reset each time a new
record is selected. If I jump a few records, the code is not following
me.

Dec 12 '05 #3
GoalieGW <Go******@ptd.net> wrote:
: Thank you, that helped. Now I need the code to reset each time a new
: record is selected. If I jump a few records, the code is not following
: me.

How do you select a record? Don't you have a control on the
form that's bound to the value that is that record's
lngcompare? I don't understand why you need to work through
the recordset instead of using that.

...but please note that I'm not one of the experts
here: I still don't see lots of things...

--thelma

Dec 12 '05 #4
Each record has a field "fldDate" that identifies it. The problem I am
having is that if I continue to hit OK and then tab, the recordset is
not reseting and starting over. It is continuing with the MoveNext
procedure. Do you know how I can use the "fldDate" to define the
recordset as current "fldDate"-1?

Dec 12 '05 #5
GoalieGW <Go******@ptd.net> wrote:
: Each record has a field "fldDate" that identifies it. The problem I am
: having is that if I continue to hit OK and then tab, the recordset is
: not reseting and starting over. It is continuing with the MoveNext
: procedure. Do you know how I can use the "fldDate" to define the
: recordset as current "fldDate"-1?

I *think* that you're working w/ two recordsets: the form's
recordset that is handling record navigation and the one that you open
in code. These are getting out of phase as you continue to change
records using the form's navigation buttons. The control that shows
the current record's fldDate is what you want to use as lngcompare.

I don't really understand what your recordset in code is for, but if
you need it, then you'll need to set its bookmark to the form's
recordset current bookmark.

Please try to open this discussion to wider participation,
because I could be completely wrong and both of us can learn from the
answers of people who do know.
--thelma
Dec 12 '05 #6

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

Similar topics

4
1980
by: Ken Fine | last post by:
I'm trying to include a list of people that's the result of looping through a recordset in a CDONTS mail. I'm trying to Dim the output of a loop, and it ain't working -- I'm getting a syntax error....
1
1263
by: technoplonker | last post by:
I am carrying out a search on an MS Access 2000 db from within a page. I know that there is more than one result to be displayed, but I can't get the code to loop to the second result onwards. This...
1
2891
by: Jack | last post by:
Hi, I am trying to add a new record to a main page. This page is the processing page to a form. However, I am getting the following error message: Error Type: ADODB.Recordset (0x800A0BB9)...
6
5502
by: deko | last post by:
Set strFoundCt = ("SELECT COUNT(*) FROM (SELECT DISTINCT Entity_ID FROM qrySearch" & strPxSx) This doesn't work, but hopefully describes what I'm trying to do. I have several different queries...
7
4334
by: Geert Elias | last post by:
Hello all, When making a new table by running a make table query based on a table, the field I added a descending sort, is not always sorted correct. When I run the query 10 times, almost 7...
1
3576
by: iam247 | last post by:
Hi I have a web page which receives information from a form (using request.form) and also attempts to look at an Access query to read in recoeds to a variable named rsGroup. When I have the...
5
1364
by: AFN | last post by:
Hi. I'm pretty comfortable binding a single recordset result to a datagrid. But now I have a more unique problem. I have 2 really long stored procedures that cannot be combined at the SQL...
6
1404
by: doncee | last post by:
This is the set up: is a date field on a form. Its control source is the field "date_entered" in"Table1". If there is a date showing in the date_entered field (Text6) & the status in Combo box2...
3
1408
by: laparico2002 | last post by:
I am quite new to VB6.0. Now am trying to create a connection to NWIND.mdb. But each time i run my program i keep getting error in "Wrong argument passed" the below were what i wrote in my MODULE ...
0
7036
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...
1
6928
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...
0
7416
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...
1
4948
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
4622
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
3115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1452
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
692
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
324
bsmnconsultancy
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...

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.