SetFocus on subform, then DoCmd.GoToRecord not working...

M

Matt P

form 1= "frmContactsAddSplit" (the original form the user starts at)
form 2= "frmContactsAdd(New)" (where the user gets sent after they
click on a listbox (lbxSortAdd) and then a button
subform 1= "subCompanyAddresses1"
subform 2= "subAdjusters2"

So all in all there are 4 four forms. I called form 2 from form 1
obviously. Form 2 is a bound form with two subforms. My final result
will be to get the form 2 and sub form 1 to be filled in with the
correct ID's from the other form and a new record in subform 2.


Here is my code from the button on frmContactsAddSplit (form 1):
Private Sub cmdANAdj_Click()
Dim strCriteria As String
strCriteria = "[ID]=" & Me![Company Name]
DoCmd.OpenForm "frmContactsAdd(NEW)", , , strCriteria
Forms![frmContactsAdd(NEW)]![tblCompanyAddresses subform].SetFocus
'DoCmd.GoToRecord , Me.txtAddressID, acGoTo, Forms!
[frmContactsAddSplit]![lbxSortAdd]
End Sub

I have the last part commented out because I still haven't got the
code to setfocus on the right subform... with the code that I have it
sets the focus on subform 2... Does anyone know why this is? It
should be putting the focus on subform 1. Anyways I have tried so
many different ways around this... anyone got any ideas for why this
may be happening?

Thanks,
Matt Pierringer
 
M

Matt P

form 1= "frmContactsAddSplit"  (the original form the user starts at)
form 2= "frmContactsAdd(New)" (where the user gets sent after they
click on a listbox (lbxSortAdd) and then a button
subform 1= "subCompanyAddresses1"
subform 2= "subAdjusters2"

So all in all there are 4 four forms. I called form 2 from form 1
obviously. Form 2 is a bound form with two subforms.  My final result
will be to get the form 2 and sub form 1 to be filled in with the
correct ID's from the other form and a new record in subform 2.

Here is my code from the button on frmContactsAddSplit (form 1):
Private Sub cmdANAdj_Click()
    Dim strCriteria As String
    strCriteria = "[ID]=" & Me![Company Name]
    DoCmd.OpenForm "frmContactsAdd(NEW)", , , strCriteria
    Forms![frmContactsAdd(NEW)]![tblCompanyAddresses subform].SetFocus
    'DoCmd.GoToRecord , Me.txtAddressID, acGoTo, Forms!
[frmContactsAddSplit]![lbxSortAdd]
End Sub

I have the last part commented out because I still haven't got the
code to setfocus on the right subform... with the code that I have it
sets the focus on subform 2...  Does anyone know why this is?  It
should be putting the focus on subform 1.   Anyways I have tried so
many different ways around this... anyone got any ideas for why this
may be happening?

Thanks,
Matt Pierringer

Heh I changed the name of sub form 1... I forgot to change it here:

Private Sub cmdANAdj_Click()
Dim strCriteria As String
strCriteria = "[ID]=" & Me![Company Name]
DoCmd.OpenForm "frmContactsAdd(NEW)", , , strCriteria
Forms![frmContactsAdd(NEW)]![subCompanyAddresses].SetFocus
'DoCmd.GoToRecord , Me.txtAddressID, acGoTo, Forms!
[frmContactsAddSplit]![lbxSortAdd]
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