Change Focus after clicking Add Record button

G

Guest

Access 2000

My form has a combo box in the form header for searching for records, the
default focus for the form. My button "Add New Record" after being clicked
opens a new record, but my "focus" is still in the combo box. I would like to
have the focus move to the first input box (OwnerName) on the main body of
the form after the user clicks the Add New Record button. I have tried
various events on the properties of the button to no avail.

Any help, suggestions appreciated.

Thanks,
James
 
B

Brian

J T said:
Access 2000

My form has a combo box in the form header for searching for records, the
default focus for the form. My button "Add New Record" after being clicked
opens a new record, but my "focus" is still in the combo box. I would like to
have the focus move to the first input box (OwnerName) on the main body of
the form after the user clicks the Add New Record button. I have tried
various events on the properties of the button to no avail.

Any help, suggestions appreciated.

Thanks,
James

OwnerName.SetFocus
 
G

Guest

Thanks Brian, but I have tried that it several events of the properties of
the button, to no avail. Can you be a little more specific?

Thanks,
James
 
B

Brendan Reynolds

You need the Current event of the Form. Setting the focus in any event of
the command button will not work, because the focus will be reset to the
default control when the form moves to the new record, which will happen
*after* any of the events of the button.

My Form_Current event procedure often looks something like this ...

If Me.NewRecord Then
Me!SomeControl.SetFocus
Else
Me!SomeOtherControl.SetFocus
End If

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
J

James

Brendan,

Then there is no way to have a user click a button, which
will open a new record and then move the focus to a box in
the form?

The current setup is: The user searches for a record
using the combo box in the form header. Then the user can
add a new form by clicking the Add Record button. Because
the focus is currently in the combo box, and stays there
even after the user clicks the Add button, I was hoping
for a way to have the focus jump down from the combo box
to the first box in the form after clicking the button.

Is there any other way to handle this senario?

Thanks,

James
 
B

Brian

James said:
Then there is no way to have a user click a button, which
will open a new record and then move the focus to a box in
the form?

I just tried this with a command button added to the header of the Customers
form in Northwind, it works just fine:

Private Sub cmdNewRec_Click()

DoCmd.GoToRecord Record:=acNewRec
CompanyName.SetFocus

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

Top