go to record in subform

jsic1210

Registered User.
Local time
Today, 05:59
Joined
Feb 29, 2012
Messages
188
Hello, I'm trying to open a form to a specific subform (from a completely different form). From frmOpenItems, I'm trying to open frmContractForm with the matching CustomerID and its subform, frmContractSub with the matching ContractID. Here is my code, but it's giving me an error:
Private Sub btnContract_Click()
'Open Contract Form
DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.CustomerID
DoCmd.GoToRecord "Forms!frmContractForm!frmContractSub.Form!ContractID=" & Me.ContractID
End Sub

How do I look for a specific subform once in the form I want?
 
First up you need to use the FindRecord method rather than the GoToRecord method. The FindRecord method will find a specific match, whilst the GotoRecord method will simply go to the First, Last, sixth record.

The next thing is that when dealing with sub-forms you will first need to set the focus the the sub-form control and then to the control on the form you wish to search.
 
I'm doing this in another form now, but I'm still having trouble. Here is my code:

'Open Open Item form
DoCmd.OpenForm "frmOpenItemsForm", , , "ContractID=" & Me.ContractID
'Find correct record
Forms!frmOpenItemsForm!frmOpenItemsSub.Form.OpenID.SetFocus
DoCmd.FindRecord Me.OpenID

Do I need any further arguments after DoCmd.FindRecord Me.OpenID (such as true, acAll, acEntire, etc.?
 
Okay, this is a dumb question: On your DB, when I click "Find Port," FRM_FindPort shows up not maximized (ie restored), but FRM_Country stays maximized. I cannot get my form to do this. (By the way, this is in a completely different form than before). It either maximizes both, or restores both to a smaller size. What settings do I need to achieve maximized main form, and small (restored) pop-up box?
 

Users who are viewing this thread

Back
Top Bottom