473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help required: with Goto record??

Hi there,

On a form I click a tickbox ("display",yes/No) that requires the recordset.
=>>Code<<--
Me!PositionClosingDate = Format(Date, "Short Date") ' when was the position
closed?
Me.Requery ' underlining query is set to display only records where
Closeposition is set to zero 0

This works sofar Ok.
I would like on the form to display the previous record not as its now,
whereas after the recordset is required the forms recordnumber = 1.
any Ideas that point me into the right direction?

kind regards

Norman
Nov 12 '05 #1
2 6498
On Fri, 7 Nov 2003 13:00:56 +1100, "Norman Fritag"
<mt*****@ozemail.com.au> wrote:

Me.Requery requeries the underlying query, which resets the current
record to the first record.
To go to the record before the one you were on, you would have to
write code similar to this:
dim rs as recordset ' assuming DAO
dim lngPrimaryKeyValue as long
Me!PositionClosingDate = Date 'no need for Format, unless you're a
bad boy and using Text field rather than DateTime field.
lngPrimaryKeyValue = Me!PrimaryKeyField ' assuming you have a long
integer primary key
Me.Requery
set rs=me.recordsetclone
rs.FindFirst "PrimaryKeyField=" & lngPrimaryKeyValue
if not rs.nomatch then
if rs.bof then
' the one we were on is the first record. Can't MovePrevious.
else
rs.moveprevious
me.bookmark = rs.bookmark 'Sync the form with the recordset.
endif
endif
rs.close 'Purists don't do this.
set rs=nothing

-Tom.
Hi there,

On a form I click a tickbox ("display",yes/No) that requires the recordset.
=>>Code<<--
Me!PositionClosingDate = Format(Date, "Short Date") ' when was the position
closed?
Me.Requery ' underlining query is set to display only records where
Closeposition is set to zero 0

This works sofar Ok.
I would like on the form to display the previous record not as its now,
whereas after the recordset is required the forms recordnumber = 1.
any Ideas that point me into the right direction?

kind regards

Norman


Nov 12 '05 #2
Tom,
thanks for the encouragment!
The code snippent caused a not found bookmark error. The code below does the
trick.
'*****start***
Dim rs As DAO.Recordset ' assuming DAO
Dim lngPrimaryKeyValue As Long

lngPrimaryKeyValue = Me.ContactID ' assuming you have a long
Me!PositionClosingDate = Date 'no need for Format, unless you're a

Set rs = Me.RecordsetClone

rs.FindFirst "ContactID=" & lngPrimaryKeyValue

If Not rs.NoMatch Then
If rs.BOF Then
' the one we were on is the first record. Can't MovePrevious.
rs.MoveNext
Me.Bookmark = rs.Bookmark
Else
rs.MovePrevious
Me.Bookmark = rs.Bookmark 'Sync the form with the recordset.
End If
End If

lngPrimaryKeyValue = Me.ContactID ' assuming you have a long
Me.Requery 'integer primary key

rs.FindFirst "ContactID=" & lngPrimaryKeyValue
Me.Bookmark = rs.Bookmark 'Sync the form with the recordset.

rs.Close 'Purists don't do this.
Set rs = Nothing
'****end****
"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:tj********************************@4ax.com...
On Fri, 7 Nov 2003 13:00:56 +1100, "Norman Fritag"
<mt*****@ozemail.com.au> wrote:

Me.Requery requeries the underlying query, which resets the current
record to the first record.
To go to the record before the one you were on, you would have to
write code similar to this:
dim rs as recordset ' assuming DAO
dim lngPrimaryKeyValue as long
Me!PositionClosingDate = Date 'no need for Format, unless you're a
bad boy and using Text field rather than DateTime field.
lngPrimaryKeyValue = Me!PrimaryKeyField ' assuming you have a long
integer primary key
Me.Requery
set rs=me.recordsetclone
rs.FindFirst "PrimaryKeyField=" & lngPrimaryKeyValue
if not rs.nomatch then
if rs.bof then
' the one we were on is the first record. Can't MovePrevious.
else
rs.moveprevious
me.bookmark = rs.bookmark 'Sync the form with the recordset.
endif
endif
rs.close 'Purists don't do this.
set rs=nothing

-Tom.
Hi there,

On a form I click a tickbox ("display",yes/No) that requires the recordset.=>>Code<<--
Me!PositionClosingDate = Format(Date, "Short Date") ' when was the positionclosed?
Me.Requery ' underlining query is set to display only records where
Closeposition is set to zero 0

This works sofar Ok.
I would like on the form to display the previous record not as its now,
whereas after the recordset is required the forms recordnumber = 1.
any Ideas that point me into the right direction?

kind regards

Norman

Nov 12 '05 #3

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

Similar topics

37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
1
by: nydiroth | last post by:
I am trying to use the following code to reset a custom counter: (I forgot where I got the code but it's not my own and I did not remove and credits, this is how it came) Function...
2
by: Susan Bricker | last post by:
Greetings. Before I begin, I have been stuck on this problem for about a 5 days, now. I have tried and just seem to be not getting anywhere. I know that the explanation is lengthy, but I am a...
3
by: kaosyeti | last post by:
i have a form that has required fields and i have a delete button, created by the wizard, that has this code for onclick: Private Sub cmddeleterecord_Click() On Error GoTo...
8
by: darnnews | last post by:
I have a form. When a person selects a publication from a listbox, this snippet of code is supposed to look up authors that correspond to that publication and populate the Author List Box, but...
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
3
by: alnug | last post by:
Hello, I'm trying to use the following code to read data from Excel files and put the data into an MS Access Table. Some of the Excel files have the tabs in the sequence Chart1, Sheet1, Sheet2 etc...
0
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file...
0
by: Gwen Crutcher | last post by:
I keep getting the error "No value given for one or more required parameters", but not sure why. Can anyone please look at my code snipet and see if you see any reason why I could be getting this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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
jinu1996
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...
0
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
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...

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.