setfocus

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

im using this code to my next button to navigate records but i want the
focus to be still in the same field i couldnt find my way to the expected
result

Me.ProductName.SetFocus
On Error GoTo Err_next_Click

DoCmd.GoToRecord , , acNext

Exit_NEXT_Click:
Exit Sub

Err_next_Click:
If Err = 2105 Then
Beep
Else
MsgBox (Str(Err) & " - " & Err.description)
End If
Resume Exit_NEXT_Click
End Sub

please help
 
You need to move the recordset before setting the focus.

Private Sub next_Click
On Error GoTo Err_next_Click

DoCmd.GoToRecord , , acNext
Me.Controls(ProductName).SetFocus

Exit_NEXT_Click:
Exit Sub

Err_next_Click:
If Err = 2105 Then
Beep
Else
MsgBox (Str(Err) & " - " & Err.description)
End If
Resume Exit_NEXT_Click
End Sub


Also, if you want to stay on the actual control that the user was on at the
time they went to press the button, you can use

Me.Controls(Screen.PreviousControl.Name).SetFocus
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, Vista
 
Mucked that up a little:

Me.Controls("ProductName").SetFocus

I forgot to include the quotation marks (").
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, Vista
 
Admit it, Bob! You're just so relieved that your beloved BoSox won't have to
face the Yankees that you can't concentrate!


Mucked that up a little:

Me.Controls("ProductName").SetFocus

I forgot to include the quotation marks (").
You need to move the recordset before setting the focus.
[quoted text clipped - 45 lines]
 
Linq - you seem to be "Missing" something :-)
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, Vista


Linq Adams via AccessMonster.com said:
Admit it, Bob! You're just so relieved that your beloved BoSox won't have to
face the Yankees that you can't concentrate!


Mucked that up a little:

Me.Controls("ProductName").SetFocus

I forgot to include the quotation marks (").
You need to move the recordset before setting the focus.
[quoted text clipped - 45 lines]
please help
 
Back
Top