By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

Move to spec'd record in form. Better to filter or use record navigation?

P: n/a
MLH
I've pretty much always applied a filter to a form to go to a specific
record - filtering out all but the desired record. Am looking for code
used to move to a specific record when keyfield value is known.

This would leave my form in a state that PGUP and PGDN would
still navigate up 'n down the dynaset. Seeking simplest methods.
Jun 4 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You can put an unbound combobox at the top of your form where the bound
column is the keyfield value of your records. Then put the following code in
the AfterUpdate event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Set Db = CurrentDB()
Set Rst = DB.OpenRecordset("NameOfRecordsourceOfYourForm")
Rst.Findfirst "[NameOfKeyfield] = " & Me!NameOfCombobox
Me.Bookmark = Rst.Bookmark
Rst.Close
Set Rst = Nothing
Set DB = Nothing

** Add your own error handling.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com

"MLH" <CR**@NorthState.netwrote in message
news:e0********************************@4ax.com...
I've pretty much always applied a filter to a form to go to a specific
record - filtering out all but the desired record. Am looking for code
used to move to a specific record when keyfield value is known.

This would leave my form in a state that PGUP and PGDN would
still navigate up 'n down the dynaset. Seeking simplest methods.

Jun 5 '07 #2

P: n/a
On Mon, 04 Jun 2007 11:38:06 -0400, MLH <CR**@NorthState.netwrote:

Rather than Steve's solution, I would use the RecordsetClone and test
if the value was found:
With Me.RecordsetClone
.Findfirst "[NameOfKeyfield] = " & Me!NameOfCombobox
if .EOF then
Msgbox "Aaaarrrrcccchhhhh!!!!!!!"
else
Me.Bookmark = .Bookmark
end if
End With

-Tom.

>I've pretty much always applied a filter to a form to go to a specific
record - filtering out all but the desired record. Am looking for code
used to move to a specific record when keyfield value is known.

This would leave my form in a state that PGUP and PGDN would
still navigate up 'n down the dynaset. Seeking simplest methods.
Jun 5 '07 #3

P: n/a
"Steve" <so***@private.emailaddresswrote in
news:VW****************@newsread3.news.pas.earthli nk.net:
You can put an unbound combobox at the top of your form where
the bound column is the keyfield value of your records. Then
put the following code in the AfterUpdate event:
Dim Db As DAO.Database
Dim Rst As DAO.Recordset
Set Db = CurrentDB()
Set Rst = DB.OpenRecordset("NameOfRecordsourceOfYourForm")
Rst.Findfirst "[NameOfKeyfield] = " & Me!NameOfCombobox
Me.Bookmark = Rst.Bookmark
Rst.Close
Set Rst = Nothing
Set DB = Nothing

** Add your own error handling.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And
Word Applications
re******@pcdatasheet.com
Why open an independent recordset?

Use the form's recordsetclone property.

all that's needed is

Me.recordsetclone.findfirst _
"[NameOfKeyfield] = " & Me!NameOfCombobox
Me.Bookmark = Me.RecordsetClone.Bookmark

no need to do all the recordset manipulation.

>

"MLH" <CR**@NorthState.netwrote in message
news:e0********************************@4ax.com...
>I've pretty much always applied a filter to a form to go to a
specific record - filtering out all but the desired record.
Am looking for code used to move to a specific record when
keyfield value is known.

This would leave my form in a state that PGUP and PGDN would
still navigate up 'n down the dynaset. Seeking simplest
methods.




--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jun 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.