Help with 'Conditional commands'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NewtoAccess
    New Member
    • May 2007
    • 32

    Help with 'Conditional commands'

    Hi.
    I have a FORMA with a BUTTON1 which opens FORMB based on the value of PORTID field as a setlink criteria.

    If No record is found during setlinkcriteria , then I would like the PORTID value of FORMA to update(copyto) only 1 of the following fields in FORMB (creating new record): PORTA or PORTZ. In order to deterrmine which field (PORTA or PORTZ) gets updated depends upon the value in the CATEGORY field found in FORMA. The value in CATEGORY would compare against an existing "text1" and "text2" I have in the code portion of the form.

    Additionally, FORMB has 2 subforms. SUBFORMPORTA shows current selection for PORTA. And SUBFORMPORTZ shows current record selection for PORTZ.

    If, There is no value entered into PORTA I dont want the SUBFORMPORTA table to be visible. Likewise if PORTZ has no value entered, I dont want SUBFORMZ to appear.

    FORMA (form)
    PORTID (field)
    CATEGORY (field)

    FORMB (form)
    PORTA (field)
    PORTZ (field)
    SUBFORMPORTA (subform1)
    SUBFORMPORTZ (subform2)

    Please Advise, thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What have you tried so far?

    Comment

    • NewtoAccess
      New Member
      • May 2007
      • 32

      #3
      The below appears in 'on Current' in properties of FORMB

      Private Sub Form_Current()
      With Me![SubformportA].Form
      If .RecordsetClone .RecordCount = 0 And Forms!FORMA![Category] = "Server" Then Me![PortA] = Forms!FORMA![PortID] Else .Visible = (.RecordsetClon e.RecordCount > 0)
      End With

      With Me![SubformportZ].Form
      If .RecordsetClone .RecordCount = 0 And Forms!FORMA![Category] = "Switch" Or Forms!FORMA![Category] = "raritan" Then Me![PortZ] = Forms!FORMA![PortID] Else .Visible = (.RecordsetClon e.RecordCount > 0)
      End With

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Does this work? If not, is it doing anything at all?

        In addition to on current you'll want to put code in the after update event of porta and portz.

        Comment

        • NewtoAccess
          New Member
          • May 2007
          • 32

          #5
          It updates the PortA and PORTZ fields as it should, but subforms do not appear at all.

          I only want the subform (PORTA or PORTZ) with a value > 0 to appear.
          For some reason that doesnt happen.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Okay, I took a look at the code. You're using Me!Subform.Form .Visible When you should be using Me!Subform.Visi ble.

            Comment

            Working...