Connecting Tech Pros Worldwide Forums | Help | Site Map

Set subform visibile on specific criteria

Newbie
 
Join Date: May 2007
Posts: 6
#1: May 29 '07
Hello,

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

msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,886
#2: Jun 1 '07

re: Set subform visibile on specific criteria


Something like this in the After Update event of the list should work ...
Expand|Select|Wrap|Line Numbers
  1.  
  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
  12.  
  13. End Sub
  14.  
Newbie
 
Join Date: Nov 2007
Location: Kansas
Posts: 2
#3: Nov 8 '07

re: Set subform visibile on specific criteria


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
  9.  
Newbie
 
Join Date: Nov 2007
Location: Kansas
Posts: 2
#4: Nov 8 '07

re: Set subform visibile on specific criteria


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!
Reply


Similar Microsoft Access / VBA bytes