Link to home
Start Free TrialLog in
Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on

Continuous Forms hide fields per record that contain no data.

Is there a way to hide fields that contain no data per each record of the continuous forms?

I need to display different data types depending on the type of Record it is.

Record types = Attachment, Hyperlink, Note, Contact Name & Phone - each  needs to display only the appropriate fields for the record type.

Any ideas is greatly appreciated>

K
Avatar of Flyster
Flyster
Flag of United States of America image

You can use a code like this in your forms On Current Event:
Private Sub Form_Current()

If Me.txtRecordType.Value = "attachment" Then
  Me.txtHyperlink.Visible = False
Else
  Me.txtHyperlink = True

End If
End Sub

Open in new window

Just change the name of your text boxes.
Flyster
Avatar of Karen Schaefer

ASKER

are you sure this is suppose to work on each record on a continuous form?
Please Define: "appropriate fields"
...with a specific example...
Because you say: Record Types=
...but what you list are DataTypes and fields:
    Attachment, Hyperlink, Note, Contact Name & Phone

So are these record Types or Datatypes?

You also say:
"hide fields that contain no data"
...but then you say:
"display only the appropriate fields"

Again, a clear, graphical example is always helpful.

JeffCoachman
sorry Jeff.

I have a dropdown that contains:
RecID   Name
1 = Hyperlink
2=Attachment
3=Notes
4=Contact

Each of these items should allow for whether which field is displayed and I only want those fields that contain data to be displayed.

See my code that almost works in updating the record, but now I would like the form to display the appropriate fields.

Dim n As Integer
   On Error GoTo cboValType_AfterUpdate_Error

n = Me.cboValType.Column(0)

    Select Case n
        Case 1 ' HYPERLINK
            Me.Hyperlink.Visible = True
            Me.Hyperlink.SetFocus
            Me.lblNotes.Visible = False
            Me.Comments.Visible = False
            Me.lblContact.Visible = False
            Me.Comments.Visible = False
            Me.lblPh.Visible = False
            Me.PhoneNumber.Visible = False
            Me.ContactName.Visible = False
        Case 2   'ATTACHMENT
            Me.Hyperlink.Visible = True
            Me.Hyperlink.SetFocus
            Me.lblNotes.Visible = False
            Me.Comments.Visible = False
            Me.PhoneNumber.Visible = False
            Me.lblPh.Visible = False
            Me.lblContact.Visible = False
            Me.ContactName.Visible = False
        Case 3 'NOTES
            Me.Hyperlink.Visible = False
            Me.Comments.Visible = True
            Me.lblNotes.Visible = True
            Me.Comments.SetFocus
            Me.lblPh.Visible = False
            Me.PhoneNumber.Visible = False
            Me.lblContact.Visible = False
            Me.ContactName.Visible = False
        Case 4 ' PHONE CONTACTS
            Me.Hyperlink.Visible = False
            Me.lblNotes.Visible = False
            Me.Comments.Visible = False
            Me.lblContact.Visible = True
            Me.ContactName.Visible = True
            Me.lblPh.Visible = True
            Me.PhoneNumber.Visible = True
            Me.ContactName.SetFocus
        Case Else
    End Select

   On Error GoTo 0
   Exit Sub

cboValType_AfterUpdate_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboValType_AfterUpdate of VBA Document Form_frmValidatation_MainSub1"
End Sub

Open in new window


Normally I just hide the fields, but due to the form being a continuous form, I need each record to reflect only the applicable fields based on the ValidationRecID Type.

Hope this helps.

K
No it won't. Sorry, forgot about that part.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jeff

Welcome to my world, this latest project has really given me some challenges, trying to push Access to do things its is not capable of.  The individual who helped make the tables come from a non-normal background and when I try to explain the need for tighter normalization, it goes on deaf ears.  Also, the client is use to a excel environment and exist that the design work they way they want it.

So I told them I would research the issue, I am pretty sure that they will have to settle for a continuous form that will display empty fields when they are not applicable.

Thanks for all you comments.

K
for you time, even though there is not really a solution for my project.