Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hide Controls (2003)

    I want to hide some controls on a form, dependant on the results of another. The control in question is a text field. I have put code in the AfterUpdate property, so if the contents are YES, the other controls disappear. It works, but when I create a new record using the form, thats the same.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    Also put the code in the On Current event of the form, so that the controls are shown or hidden as appropriate when the user moves to another record.

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    I put the code in the On Current event, and everything worked fine. I've just added a button to insert an image, and when I open the form, I get an error message saying 'the expression On Current you entered as the event property setting produced the following error: Cannot define a Public User-Defined type within an object module. Why should adding this button cause a problem with the On Current event?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    Without seeing the code, it's hard to say. Make sure that you haven't given a module the same name as a variable or control.

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    Thanks Hans, sorted. Must have typed something in wrong, but couldn't find anything. I deleted all the code, started again, and it's ok. One small thing that's happening though, is when images have been put into a record, as you move from record to record, an 'importing image' dialogue pops up briefly. Is there any way this could be hidden or stopped?

  6. #6
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    Should putting code in OnCurrent and After Update, work with hiding subforms as well? I thought it had worked, but it hides the subform in all the records not just the one.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    See API: Suppress the "Loading Image" dialog for two methods. The second one doesn't do much for me - it doesn't suppress the dialog, it only tries to remove it quickly.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    I'm not sure what you mean. What kind of form is the main form, and where is the subform?

  9. #9
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    It's the tabbed form from a previous thread. I have inserted a subform into one of the tabs.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    The code in the On Current event of the main form should hide or show the subform as needed.

  11. #11
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    That's what I thought, but what ever action I make on another record, has an effect on the others ie., if I hide the form in record 1, record 2 is also hidden. If I then unhide record 2, record 1 is also visible.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    I'm lost. What does "if I hide the form in record 1, record 2 is also hidden" mean? You're hiding a subform IN a record and this causes another record to be hidden? Where are these records?

  13. #13
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    Let me try to explain it clearer. If a control on the main form is YES, then the subform should be hidden. If I create a new record on the main form, the subform is still hidden.

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Controls (2003)

    What is the code you are using in the On Current event to show/hide the subform?

  15. #15
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Controls (2003)

    Here's the code. It's the last bit, IF Me.Use_standard2 that seems to be not working

    Private Sub Form_Current()
    On Error GoTo HandleErr
    If Not IsNull([PicFile]) Then
    [imgPicture].Picture = [PicFile]
    SysCmd acSysCmdSetStatus, "Image: '" & [PicFile] & "'."
    Else
    [imgPicture].Picture = ""
    SysCmd acSysCmdClearStatus
    End If
    Exit Sub

    HandleErr:
    If Err = 2220 Then
    [imgPicture].Picture = ""
    SysCmd acSysCmdSetStatus, "Can't open image: '" & [PicFile] & "'"
    Else
    MsgBox Err.DESCRIPTION, vbExclamation
    End If




    If Me.Injection_Technique = "YES" Then
    Me.TOOL_ASSY.Visible = False
    Else
    Me.TOOL_ASSY.Visible = True
    End If

    If Me.Injection_Technique = "YES" Then
    Me.TOOL_STRIP_DOWN.Visible = False
    Else
    Me.TOOL_STRIP_DOWN.Visible = True
    End If

    If Me.Injection_Technique = "YES" Then
    Me.OPERATOR_COMMENTS1.Visible = False
    Else
    Me.OPERATOR_COMMENTS1.Visible = True
    End If

    If Me.USE_STANDARD2 = "YES" Then
    Me.frmTechnique.Visible = False
    Else
    Me.frmTechnique.Visible = True
    End If

    End Sub

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •