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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to change a sub-form

Status
Not open for further replies.

dominicg123

Technical User
Jan 5, 2007
23
CA
I have a form called main that I use for a menu on the left side of the screen. I use an option group with the following code to navigate between different sub-form that are use to display information:

Select Case Me![Menu Options]

Case 1
Me![DisplayPanel].SourceObject = "Contacts"
Case 2
Me![DisplayPanel].SourceObject = "Contacts List"
Case 3
Me![DisplayPanel].SourceObject = "Actions"
Case 4
Me![DisplayPanel].SourceObject = "Loans"

end select

When I am in Actions sub-form I want to display the Contact sub-form with a specific record in the form (filter). Actions and Contacts are related. This is what I tryied:

Private Sub btnGoToContact_Click()

Form![Main]![DisplayPanel].SourceObject = "Contacts"
Form![Contacts].Filter = "[Contact ID]=" & Me.ContactID


End Sub

I get object required error message
 
Thank you, the first step work perfectly but my filter gives me an error message. Its look like the form "Contacts" is not activated yet so I cannot filter it.
 
What error does it give you? Have you check the value of Me.ContactID? Is [Contact ID] numeric? I notice you have two versions of the name Contact ID, one with a space and one without, is that correct?



 
Yes it is correct. Actually anything that I try to do on the contact form doesn’t work. For example I tried to .setfocus on a specific field…
 
Did you look at the link I posted? It seems likely that you are referring to the form rather than the subform control.
 
Thank you !!

This is my final code and it work:
Private Sub btnGoToContact_Click()
Dim con As Long

con = Me.ContactID
DoCmd.Close , "Actions"
Forms![Main]![DisplayPanel].SourceObject = "Contacts"
Forms![Main]![Menu Options].Value = 1
Forms![Main]![DisplayPanel].Form.Filter = "[Contact ID]=" & con


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top