Show / Hide Subform

L

l

I am working with a conditional script to show/hide a subform. The
name of the subform happens to already have a space in it ("Orders
Subform"). Could this cause problems? My subform has the name "Orders
Subform", yet I get an error message when I include it.

Can anyone suggest steps to take in debugging this? Thanks - Louis

Currently, I am using the following script in the "parent" form:
---------------------------------------
Private Sub EmployeeID_Change()
On Error Resume Next

Dim strSubformName As String

' Based on the page selected, set the Subform Name variable
Select Case Me.EmployeeID
Case 0: strSubformName = ""
Case 1: strSubformName = "Orders Subform"
Case Else: strSubformName = "apple"
End Select

' If a subform exists, then set the properties, otherwise
' just hide the generic subform object
If strSubformName = "" Then
Me.Orders Subform.Visible = False

Else

Me.Orders Subform.SourceObject = strSubformName
Me.Orders Subform.LinkMasterFields = "pub_id"
Me.Orders Subform.LinkChildFields = "pub_id"

Me.Orders Subform.Visible = True
End If

End Sub
 
P

Pieter Wijnen

I personally *hate* Variables, Objects Tables and Or Fields with spaces
but
Me.[Orders Subform].Visible = False
or
Me.Orders_Subform.Visible = False
should both work

Pieter

Hungarian notation was invented to avoid this
ie use

ALPHA_ALPHA (MSSQL & Oracle do Support mixed case as in "My Table" instead
of MY_TABLE but you have to enquote & type exactly as defined)
or
AlphaAlpha (For Forms & Reports - OrdersSubForm is just as readable)
 
P

Pieter Wijnen

I personally *hate* Variables, Objects Tables and Or Fields with spaces
but
Me.[Orders Subform].Visible = False
or
Me.Orders_Subform.Visible = False
should both work

Pieter

Hungarian notation was invented to avoid this
ie use

ALPHA_ALPHA (MSSQL & Oracle do Support mixed case as in "My Table" instead
of MY_TABLE but you have to enquote & type exactly as defined)
or
AlphaAlpha (For Forms & Reports - OrdersSubForm is just as readable)





l said:
I am working with a conditional script to show/hide a subform. The
name of the subform happens to already have a space in it ("Orders
Subform"). Could this cause problems? My subform has the name "Orders
Subform", yet I get an error message when I include it.

Can anyone suggest steps to take in debugging this? Thanks - Louis

Currently, I am using the following script in the "parent" form:
---------------------------------------
Private Sub EmployeeID_Change()
On Error Resume Next

Dim strSubformName As String

' Based on the page selected, set the Subform Name variable
Select Case Me.EmployeeID
Case 0: strSubformName = ""
Case 1: strSubformName = "Orders Subform"
Case Else: strSubformName = "apple"
End Select

' If a subform exists, then set the properties, otherwise
' just hide the generic subform object
If strSubformName = "" Then
Me.Orders Subform.Visible = False

Else

Me.Orders Subform.SourceObject = strSubformName
Me.Orders Subform.LinkMasterFields = "pub_id"
Me.Orders Subform.LinkChildFields = "pub_id"

Me.Orders Subform.Visible = True
End If

End Sub



--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top