Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor postion after refresh 1

Status
Not open for further replies.

logopolis

Technical User
Oct 10, 2002
59
0
0
ES
I am using the following code on a subform (which is in the form of a list)

Private Sub Course_ID_Change()
On Error GoTo Err_Course_ID_Change

Forms![Information Input].Refresh

Exit_Course_ID_Change:
Exit Sub

Err_Course_ID_Change:
MsgBox Err.Description
Resume Exit_Course_ID_Change

End Sub

It works well and does refresh the code but the cursor returns to the 1st record in the list after each entry. Is there a way to make the cursor go to the next record after refreshing.

John
 
How are ya logopolis

Try the DoCmd.GotoRecord method.

Calvin.gif
See Ya! . . . . . .
 
Hi!

Normally a refresh doesn't change the cursor position (or current record), so I'm gussing there might be some other code doing a requery?

Well, the ususal way of "returning" to the current record after doing a requery, is to capture the primary key value, and issue a .FindFirst:

[tt]dim lPK as long
dim rs as dao.recordset
lPk=me!txtPK.Value
me.requery
set rs=me.recordsetclone
rs.findfirst "PKField = " & lPK
if not rs.nomatch then
me.bookmark=rs.bookmark
end if
set rs=nothing
' then moving to the next record, perhaps
docmd.gotorecrod,,acNext[/tt]

- in this sample, all is performed within the current form and the primary key is one numeric field - typed not tested, requires a reference to the Microsoft DAO 3.# Object Library (in VBE - Tools References)

Roy-Vidar
 
Hi AceMan1

Thanks for the help. I have put the line

DoCmd.GoToRecord acDataForm, "Daycare Choice subform", acGoTo, acLast

But whe i run it it tells me that the Subfrom isnt open.

Any ideas

John
 
logopolis . . . .

[blue]RoyVidar[/blue] is right . . . . you need to findout whats shifting your focus first. Chances are you won't have to bother with this. So follow his post.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top