going to new record in subform on tab page

pbuethe

Returning User
Local time
Today, 14:59
Joined
Apr 9, 2002
Messages
210
I have the following code:

Private Sub pgARVTherapy_Click()

Forms![frmPartA]![sfrmARVTherapy].SetFocus
DoCmd.GoToControl "DrugCode"
DoCmd.GoToRecord , "", acNewRec

End Sub

When I click on the tab (pgARVTherapy), I want to go to a new record in the subform on that tab page, with the cursor on the field DrugCode. The subform is a continuous form. The cursor is on the first record instead.

Thanks for your help.
 
Try:

Forms![frmPartA]![sfrmARVTherapy].SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec
DoCmd.GoToControl "DrugCode"
 
dan-cat, Thanks for your reply. It did not work, however. I need to click in the main form to get it to go to the new record. Is there perhaps a way to simulate a click?
 
Can you post ot email your db so I can take a closer look?
 
I am not sure if I am allowed, although the db does not contain any real data yet.

I did get this to work in another db, on the OnCurrent event of the main form. (It did not have tab controls). This time it didn't work on the OnCurrent event either. In the OnCurrent event, I tried to determine if it was the correct page of the tab by:

if Me![tabPartA].Value = 4 then

(4 is the page index of the page the subform is on)

Is this syntax correct?
 

Users who are viewing this thread

Back
Top Bottom