Default and mandatory field functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cyberdyne
    Recognized Expert Contributor
    • Sep 2006
    • 627

    #16
    How do I make row source appear in my checkbox?

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #17
      What do you mean Cyber?
      Are you referring to the 'Control Source' by any chance?

      Comment

      • Cyberdyne
        Recognized Expert Contributor
        • Sep 2006
        • 627

        #18
        Ok I got it now

        How can I make field 2 Mandatory? In other words I want it to have a value that a person will choose from the list, but if you don't choose you can't proceed.

        let me know thanks

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #19
          Originally posted by Cyberdyne
          Ok I got it now

          How can I make field 2 Mandatory? In other words I want it to have a value that a person will choose from the list, but if you don't choose you can't proceed.

          let me know thanks
          My guess is you will just need to code that yourself. Probably something like...
          Code:
          Private Sub Form_BeforeUpdate(Cancel As Integer)
            ' If your Field1 checkbox is ticked Then
              ' If you don't like the contents of field2 Then
                Cancel = True
                MsgBox "Get it right, dopey!"
              ' End If
            ' end If
          End Sub

          Comment

          • Cyberdyne
            Recognized Expert Contributor
            • Sep 2006
            • 627

            #20
            Originally posted by Killer42
            My guess is you will just need to code that yourself. Probably something like...
            Code:
            Private Sub Form_BeforeUpdate(Cancel As Integer)
              ' If your Field1 checkbox is ticked Then
                ' If you don't like the contents of field2 Then
                  Cancel = True
                  MsgBox "Get it right, dopey!"
                ' End If
              ' end If
            End Sub

            Where would I insert this code? In Field1 or Field2 and where in those fields?

            So I will right click on the field go to properties go to Event and then in Before Update I will go in to the code and copy and paste that code?

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #21
              Originally posted by Cyberdyne
              Where would I insert this code? In Field1 or Field2 and where in those fields?

              So I will right click on the field go to properties go to Event and then in Before Update I will go in to the code and copy and paste that code?
              No, this is the BeforeUpdate event for the form. If this is the correct place for it (it was just a suggestion, after all) you would need to set the Before Update event on the form to [Event Procedure]. Then click the ... to go to the code editor, and insert this code. Note that the procedure declaration (the Private Sub and End Sub lines) will already be filled in, so skip those.

              Also, I hope you realise that this code won't run as-is. A lot of it is made up of comments simply showing where to put your code. For example, where it says ' If your Field1 checkbox is ticked Then you need to put the code to test the checkbox.

              Comment

              • Cyberdyne
                Recognized Expert Contributor
                • Sep 2006
                • 627

                #22
                I got it, its working fine, I am able to make it appear once I check field one. For some reason its still not mandatory though, I can still continue onto the next entry without the "Please Enter the name of the User for Field 2"

                Any suggestions?

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #23
                  Originally posted by Cyberdyne
                  I got it, its working fine, I am able to make it appear once I check field one. For some reason its still not mandatory though, I can still continue onto the next entry without the "Please Enter the name of the User for Field 2"
                  Can you post the code, so we can see exactly how you implemented it? It usually turns out to be some teeny little detail that's slightly different, so you need to see the actual code to find it.

                  Comment

                  • George Oro
                    New Member
                    • Jan 2007
                    • 36

                    #24
                    Hope I understand you correctly: Lets add Field3, Field4 and Field5
                    Set Field2-5 to

                    Enabled=False
                    Locked=True
                    'and
                    Me.Field1="No"

                    then on AfterUpdate event of Field1 put this:
                    Code:
                    If me.Field1.value="Yes" then
                     me.Field2.Enabled=True
                     me.Field2.Locked=False
                    else
                     me.Field2.Enabled=false
                     me.Field2.Locked=true
                    end if
                    then put this on AfterUpdate event of Field2:
                    Code:
                    If not isnull(me.field2) then
                    ' enable and unlock the rest of the fields
                    end if
                    The above will really force the user user to enter value in Field2 before going to other fields but if the user select "No" then no data entry will happen or just the Field1 will be filled-in.

                    HTH,
                    George



                    Originally posted by Cyberdyne
                    I have two fields

                    Field1 - has options Yes or No
                    Field2 - has three options to chose from

                    First: What do I need to do to make Field1 be No and Field2 not selectable by default?

                    Second: If Field1 is selected as Yes I want Field2 to become selectable and mandatory.

                    Let me know, Cyberdyne.

                    Comment

                    Working...