Requery a Continuous Form

R

Reggie Laffond

I'm sorry if this is a multiple post but I sent it several times and I
haven't seen it on the newsgroup hours later.

I have a continuous form with a unique customer key as one of the fields on
each line. Is there a way in code to determine the value of the key field
that is in the first row? If I use Forms!frmMain.KeyField I get the row that
has focus but I want row 1 no matter what row has focus.

I want to reposition the form exactly as it was before I issued a
"Forms!frmMain.Requery" in code.

Thanks for the help.
 
S

Stephen Lebans

See the SelTop sample Form here:
http://www.lebans.com/setgetsb.htm
SetGetSB.zip is a database containing functions to allow a user to Set or
Get the current position of a ScrollBar Thumb for a Form.

NEW - Apr. 02/2000 The current ScrollBar position is equal to the current
Record Number being displayed at the Top of the Form.

Works in Form or Datasheet view.

Ver 1.7

Fix bug in SelTop method. Now works with first page of rows properly and
sets the Top row correctly when moving forward in the recordset one row at a
time.

Ver 1.6

Use SelTop to save Restore current row's position after a Requery.

Ver 1.5

Added support for Horizontal ScrollBars.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
B

Bob Hairgrove

I'm sorry if this is a multiple post but I sent it several times and I
haven't seen it on the newsgroup hours later.

I have a continuous form with a unique customer key as one of the fields on
each line. Is there a way in code to determine the value of the key field
that is in the first row? If I use Forms!frmMain.KeyField I get the row that
has focus but I want row 1 no matter what row has focus.

I want to reposition the form exactly as it was before I issued a
"Forms!frmMain.Requery" in code.

Thanks for the help.

There's no need to requery unless the data has been changed by another
form or user.

I would use the form's RecordsetClone to do this. Don't know if you
are using DAO or ADO, but here's how with DAO:

Dim rst As DAO.Recordset
Dim keyvalue As Long ' assuming KeyField has type Long here...
Set rst = Forms!frmMain.RecordsetClone
' don't do this on an empty recordset:
If rst.RecordCount > 0 Then
rst.MoveFirst
' use the name of the field, NOT the form control here:
keyvalue = rst!KeyField
EndIf
Set rst = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top