Check box automatically checked if certain fields in the table contain data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ecirtaeb
    New Member
    • Aug 2011
    • 3

    Check box automatically checked if certain fields in the table contain data

    How can I make a checkbox change to Yes if certain fields in the table contain data, in my case hyperlinks.

    For example,the checkbox changes automatically to yes if the field 1 or field 2 or field 3 (or a combination of these) contain hyperlinks to external documents.

    The database I am currently working is an Access 2003.

    Your help is greatly appreciated.

    Thank you

    Best,

    Sorry, I forgot to mention that I am working on Access 2003 environment.
    Last edited by Niheel; Aug 17 '11, 03:14 PM.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    This is exactly what the concept of normalisation (See Database Normalisation and Table structures) warns against doing. I suggest you avoid storing the info and simply query for that whenever required.

    Technically, it can be done of course (should you choose to ignore the advice and head down the more troublesome road). A private procedure in your form's module could set the value to match checks for the existence of each, all ORed together :
    Code:
    Private Sub SetCB()
        With Me
            .CB = (Not IsNull(.[Field 1])) Or _
                  (Not IsNull(.[Field 2])) Or _
                  (Not IsNull(.[Field 3]))
        End With
    End Sub
    The AfterUpdate event of the three "Field" controls would each call this procedure.

    EG. :
    Code:
    Private Sub Field_1_AfterUpdate()
        Call SetCB
    End Sub

    Comment

    • Ecirtaeb
      New Member
      • Aug 2011
      • 3

      #3
      Hi NeoPa,

      thank you for the code.

      I think the problem with applying this code to my form is that the Field 1, Field 2, and Field 3 reside in a pop-up form and they are used for hyperlinks to extenal documents.

      Now, the checkbox that will let me know that there are attachments for a certain record reside on the main form.

      However, all the three fields do reside on the main table that the main form is based on.

      How can I apply the above code to this scenario.

      All the help is very appreciated.

      Thank you very much,

      Best.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        I don't think you can. The suggested code was for the question you posted.

        If you want to change the question then I suggest you post the relevant details first. That way I don't waste any more time than absolutely necessary.

        By the way, did I mention that proceeding in this non-normalised way is liable to lead you into all sorts of problems? I guess I did - but such an important point bears repetition.

        Comment

        • Ecirtaeb
          New Member
          • Aug 2011
          • 3

          #5
          Thank you NeoPa,

          I wished I could do something better for this database but it was already so purely set up before I started to implement it.

          I decided to leave the check box and if attachments related to a certain record exist, the user will have to click the box manually.

          Thank you again for your help and sorry for the inconvenience my first question created.

          Best,

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Originally posted by NeoPa
            NeoPa:
            I don't think you can.
            This refers specifically to the question you asked.
            Originally posted by Ecirtaeb
            Ecirtaeb:
            How can I apply the above code to this scenario.
            That is to say "The above code cannot be applied", but not "No code can be applied".

            To help with any code that could work though, we'd need to see some details of your situation. Names of objects, how they all fit together, etc.

            Comment

            Working...