setfocus

M

mccoy

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
 
B

boblarson

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
 
B

boblarson

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
 
L

Linq Adams via AccessMonster.com

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]
 
B

boblarson

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
 

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