After Add Record, Put Cursor in specific Text Box

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
 
A

Allen Browne

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 

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

Similar Threads

Combining code isn't working 5
methods aren't being listed. 3
Problem clearing listbox 4
Access forms "add record" 5
Jet Engine Error Message 2
Access Pop-Up Calendar 2
lock button 15
Open new form 1

Top