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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetFocus on Continuous form after Requery 1

Status
Not open for further replies.

waubain

Technical User
Dec 13, 2011
200
US
I have a continuous form with a column PriorityNum. The purpose of this column is to be able to display in what order I want the records to appear. I have two command buttons that move a record up one or down one depending on which is clicked. All this works fine. This is the code for the down button

Code:
' Moves PriorityNum down by one

Private Sub cmdDownArrow_Click()

If Me!PriorityNum >= DMax("PriorityNum", "tblStudy") Then
MsgBox "This record cannot move down"
Exit Sub
End If
Dim NewPos As Integer
NewPos = Me!PriorityNum + 1
Me!PriorityNum = NewPos
DoCmd.GoToRecord , , acNext
Me!PriorityNum = Me!PriorityNum - 1
Me.Requery

What does not work is which row is highlighted after the requery. The highlighted row is the first row. I tried to add the following two lines of code at the end of the above code but am getting a "Method or Data Member not found"

Code:
Me.PriorityNum.SetFocus
DoCmd.FindRecord NewPos

If I was on record 8 and I click the down button then record 8 becomes record 9 and 9 become 8. I then want the cursor to be on record 9.

Am I missing something? Thanks

You don't know what you don't know...
 
Try the recordset findfirst method
me.recordset.findfirst "PriorityNumber = " & NewPos

Yours should work if the control is names PriorityNumber. My guess is you only have a field with that name, and a field does not have a setfocus method.
 
Many thanks MajP.

Your solution worked perfectly. Your guess was correct PriorityNum is only a field, since its purpose is only to sort.



You don't know what you don't know...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top