After Add Record, Put Cursor in specific Text Box

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

Guest

Hi, I had the wizard set up a button to add record (it puts in the code
below in the On Click property of the button). I'd then like to have the
focus go to text box [ProjectType]. I don't know how to do that. TIA :)

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub
 
Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click

If Me.Dirty Then Me.Dirty = False
If Not Me.NewRecord Then RunCommand acCmdRecordsGotoNew
Me.[Project Type].SetFocus

Exit_cmdAddRecord_Click:
Exit Sub

Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click
End Sub
 
Thank you - but where do I put that?

Ofer Cohen said:
Try

Me.[ProjectType].SetFocus

--
Good Luck
BS"D


Karin said:
Hi, I had the wizard set up a button to add record (it puts in the code
below in the On Click property of the button). I'd then like to have the
focus go to text box [ProjectType]. I don't know how to do that. TIA :)

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub
 
I got it (it works but I don't know if its really right):

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Me.[ProjectType].SetFocus
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub


Ofer Cohen said:
Try

Me.[ProjectType].SetFocus

--
Good Luck
BS"D


Karin said:
Hi, I had the wizard set up a button to add record (it puts in the code
below in the On Click property of the button). I'd then like to have the
focus go to text box [ProjectType]. I don't know how to do that. TIA :)

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub
 
Hi,
Move it from the Exit_cmdAddRecord_Click section, other wise if there is an
error it will run this line of code and might produce another error


Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click

DoCmd.GoToRecord , , acNewRec
Me.[ProjectType].SetFocus

Exit_cmdAddRecord_Click:
Exit Sub

Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub


--
Good Luck
BS"D


Karin said:
I got it (it works but I don't know if its really right):

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Me.[ProjectType].SetFocus
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub


Ofer Cohen said:
Try

Me.[ProjectType].SetFocus

--
Good Luck
BS"D


Karin said:
Hi, I had the wizard set up a button to add record (it puts in the code
below in the On Click property of the button). I'd then like to have the
focus go to text box [ProjectType]. I don't know how to do that. TIA :)

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub
 
Perfect - thank you.

Ofer Cohen said:
Hi,
Move it from the Exit_cmdAddRecord_Click section, other wise if there is an
error it will run this line of code and might produce another error


Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click

DoCmd.GoToRecord , , acNewRec
Me.[ProjectType].SetFocus

Exit_cmdAddRecord_Click:
Exit Sub

Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub


--
Good Luck
BS"D


Karin said:
I got it (it works but I don't know if its really right):

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Me.[ProjectType].SetFocus
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub


Ofer Cohen said:
Try

Me.[ProjectType].SetFocus

--
Good Luck
BS"D


:

Hi, I had the wizard set up a button to add record (it puts in the code
below in the On Click property of the button). I'd then like to have the
focus go to text box [ProjectType]. I don't know how to do that. TIA :)

Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_cmdAddRecord_Click:
Exit Sub



Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click

End Sub
 
Back
Top