Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving between forms and subforms and back !!!!!Help!!!!

Status
Not open for further replies.

DBritter

Technical User
Jun 28, 2000
37
US
The problem comes when trying to set the focus back to the main form from a subform. I have used the .GoToControl action after the lost focus event to have the person go directly into the subform. exiting the subform I tried to do the same thing,but I keep getting an error saying the field is not in the record.

The FAQ section dealing with syntax was a little confusing to me.

Attached is the procedure I used to get to the subform.


Private Sub ysnWorkNewConstruction_LostFocus()
On Error GoTo ysnWorkNewConstruction_Err:
DoCmd.GoToControl "fsubSpecificationFrequencyfrmChangeContactInformation"
DoCmd.GoToControl "ysnSpecifyBasinGrate"
ysnWorkNewConstruction_Exit:
Exit Sub
ysnWorkNewConstruction_Err:
MsgBox Error$
Resume ysnWorkNewConstruction_Exit
End Sub

I would appreciate any help. thanks

 
You need to properly refer the either the form or subform control. Many take the easy way out and only refer to the control by its control name in the code but when the control is not on the form with the focus the code needs to be specific. Also, even if the control is found on the form, unless you use the Me. object access flails around looking for the control, taking time away from your application. These two examples are right out of the help file for Access.

Forms![Orders]![OrderID]
Forms![Orders]![Orders Subform]![Quantity]

Steve King Growth follows a healthy professional curiosity
 
Attached is the code that is placed o the last field of the subform:
Private Sub txtSpecifyMicroIrrigationFrequency_LostFocus()
On Error GoTo txtSpecifyMicroIrrigationFrequency_Err
DoCmd.GoToControl "[Forms]![frmChangecontactInformation]![lstDollarVolume]"

txtSpecifyMicroIrrigationFrequency_Exit:
Exit Sub
txtSpecifyMicroIrrigationFrequency_Err:
MsgBox Error$
Resume txtSpecifyMicroIrrigationFrequency_Exit

End Sub

It is not finding the [lstDollarVolume] field in the [frmChangecontactInformation] form. It says that the field can not be found in the record.
 
You are using the reference improperly as a string. The reference is part of the object model. Change it from:

DoCmd.GoToControl "[Forms]![frmChangecontactInformation]![lstDollarVolume]"

To

DoCmd.GoToControl [Forms]![frmChangecontactInformation]![lstDollarVolume]

Steve King Growth follows a healthy professional curiosity
 
I have changed that and am now getting an error saying:

"There is no field named '[whatever value is in the list box at the time]'in the current record."
What does this mean
 
Try replacing

Code:
DoCmd.GoToControl "[Forms]![frmChangecontactInformation]![lstDollarVolume]"

with

Code:
Parent.lstDollarVolume.SetFocus


Lightning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top