Referencing a subform field?

WinDancer

Registered User.
Local time
Today, 01:41
Joined
Oct 29, 2004
Messages
290
I have fought with this for more than an hour.

I have tried various combinations to no avail. I finnaly just did it exactly like a previous thread that I found using the search feature.

I get an error message=Application defined or Object defined error 2465

Event=AfterUpdate of Combo29
Move focus to next user field Combo13

Form=ChooseActivity
Current Field=Combo29

SubForm=ChooseParticipant
Desired field=Combo13

Forms!ChooseActivity.ChooseParticipant.Combo13.SetFocus

Why wont this run?

Thanks,
Dave
 
i think you need a !combo13, not a .combo13
yuo also dont need the space in setfocus

if you are on the parent then simply

subdetails!combo13.setfocus should work.
If you are already in the subform then just combo13.setfocus will work

i think this expression is not correct anyway for a fully specified subform

Forms!ChooseActivity.ChooseParticipant.Combo13.Set Focus

its something like
Forms!ChooseActivity!ChooseParticipant!Combo13.SetFocus

not surewithout playing with it
 
I've tried those- the one I was sure would work is
its something like
Forms!ChooseActivity!ChooseParticipant!Combo13.Set Focus

but that returns an object not found error...

Thanks for trying, I appreciate the help found here :)
 
Howzit

Check out the site below, which shows you the syntax to reference controls on subforms etc. I think you may be missing the .form part. Something like...

Code:
Forms!ChooseActivity.ChooseParticipant.Form!Combo13.SetFocus


http://www.mvps.org/access/forms/frm0031.htm
 
That code created the following error:
Application-defined or object-defined error
 
Howzit


Note that the ChooseActivity relates to the container name (the name of the subform control that holds the subform), not the subform it self.

I can't get it to work on the one line, maybe someone else has some idea


Code:
Forms!ChooseActivity.ChooseParticipant.SetFocus
Forms!ChooseActivity.ChooseParticipant.Form!combo13.SetFocus
 
Same error message...

Here is the entire code for after update:
It is selecting the record that matched the choice in combo29 on the main for, closing the previous form, and then moving the focus to combo13 on the sub form...

Private Sub Combo29_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Title] = '" & Me![Combo29] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Pause (1)
DoCmd.Close acForm, "frmMasterEnrollment"

'Forms!ChooseActivity.ChooseParticipant.Form!Combo13.SetFocus
'Forms!ChooseActivity!ChooseParticipant!Combo13.SetFocus
'Me.ChooseParticipant.Combo13.SetFocus
'Me!Subform1.Form!ControlName
'Me!ChooseParticipant.Form!Combo13.SetFocus
'Me!Subform1.Form!Subform2.Form!ControlName
'[Subform Control Name].Form![Control Name]
'Forms!ChooseActivity!Form!ChooseParticipant!Combo13.SetFocus
'Me!Subform1.Form!Subform2.Form.RecordSource

Forms!ChooseActivity.ChooseParticipant.SetFocus
Forms!ChooseActivity.ChooseParticipant.Form!Combo13.SetFocus



End Sub
 
Where exactly does it error? You can put a stop (after the DIm rs as object write stop) in your code then step through using the f8 key. See where it errors.

Have you checked thename of the subform control? If you haven't changed the default name of the subform control, it will show as child14 or something. Do not confuse the name of the form you put onto the subform control, to the subform control itself.

I created a form and subform with the code below and it works fine.
 
I went back and double checked all the names-
I deliberately did NOT use the standard frm for these two forms, and started oth names with the word 'choose' so I could keep them separate from similar forms.
The form I created and used as the sub-form is listed under the forms as 'ChooseParticipant'.
When I got into the form in design view it was listed as 'frmChooseParticipant'.

I apologize- when I changed your last bit of code to include the 'frm' it works flawlessly.

I did learn a valuable lesson from this.

Thank You for hanging in there :)

Dave
 

Users who are viewing this thread

Back
Top Bottom