Set Focus to add new record on subform

J

Jon M.

Hello All, I come begging for advice once again. I have a form linked with a
subform(datasheet). On my main form I have an option group with two options,
Borrowing = 1 and Returning = 2. My main form lists equipment details, my
subform lists borrower details. I am trying to get it to work so that when I
select Borrowing from my option group, it sets the focus on a new record of
my subform. I used this:

If Me!ActionItem = 1 Then
Borrower_Subform!Borrower.SetFocus
DoCmd.GoToRecord , , acNewRec
End If

However this takes me to a new record on my main form, which is not what I'm
trying to do. Is what I'm looking for possible? And if so Can you help me
find what I'm missing?

I would also like to try and set the focus to a specific field on an
existing record on my subform when the returning option is selected from my
option group if that's possible, but baby steps. So that when I choose the
option it takes to the Date_Returned field of the last record of the subform.
As always any advice is greatly appreciated.
 
J

Jon M.

Like a charm that worked. Thank you.
Any thoughts on how I could get it so if Returning were selected i could set
the focus to the field Date_Returned of the last record in my subform?
 
C

Clifford Bass

Hi Jon,

I would think either of these should do the trick after you set the
focus to the form:

DoCmd.RunCommand acCmdRecordsGoToLast

or

DoCmd.GoToRecord , , acLast

Then I would think you could set the focus to the Date_Returned control
with this:

Borrower_Subform.Form!Date_Returned.SetFocus

Clifford Bass
 

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