By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,667 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,667 IT Pros & Developers. It's quick & easy.

Set subform visibile on specific criteria

P: 6

I need to know if in VB it is possible to set a subform that is visible sometimes and others invisible, to a selected record. For example on a separate Cmd click I have a separate form open up with the selected record. The code reads:

DoCmd.OpenForm "frm_contactsEdit", , , "[ContactID]=" & Me.ListContact

I need my visible comand to follow a similar procedure of setting to a specific record. It is not possible to link the subform and from because my form is not bound to any object.

Any help would be appreciated.

Oxford Consulting
May 29 '07 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 10K+
P: 14,534
Something like this in the After Update event of the list should work ...
Expand|Select|Wrap|Line Numbers
  2. Private Sub ListContact_AfterUpdate()
  3.     If nz(DLookup("[ContactID]", "TableName", "[ContactID]=" & Me.ListContact),"") = "" Then
  4.        Me!SubformObjectName.Visible = False
  5.        Me!SubformObjectName.Filter = ""
  6.        Me!SubformObjectName.FilterOn = False
  7.     Else
  8.        Me!SubformObjectName.Visible = True
  9.        Me!SubformObjectName.Filter = "[ContactID]=" & Me.ListContact
  10.        Me!SubformObjectName.FilterOn = True
  11.     End If
  13. End Sub
Jun 1 '07 #2

P: 2
I tried this technique, using Access 2003 with SP3. Apparently the interpreter thinks that the subform name is the name of a field on the form. It throws an error message 2465, "Microsoft Access Cant find the field 'NameOfSubForm' referred to in your expression". Any other ideas anyone?
Expand|Select|Wrap|Line Numbers
  1. Private Sub SetVisibles()
  2.     Select Case cboAssessType
  3.         Case "G" ' General Education
  4.             Me!frmGenEdCoreReqs.Visible = True
  5.         Case Else
  6.             Me!frmGenEdCoreReqs.Visible = False
  7.     End Select
  8. End Sub
Nov 8 '07 #3

P: 2
Never mind! Still part of the old school that think any time I am referring to a form, I need the Bang as the separator. Substituting the dot for the bang in my code worked just great!
Nov 8 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.