• Value gets missed (Access97)

    Author
    Topic
    #415866

    I have a form with text (can have list). If there is a value in the box – message should be displayed. If not – run Macro.

    If Forms![Update_master-data-charges]!txt_Check_Dates.Value = True Then
    MsgBox “Data for this Pay Period is exists in the master-data-charge table”

    Else
    DoCmd.RunMacro “Run_Update_master-data-charges”

    End If

    and it is showing Message value or no value.

    It seems like value in the box gets un-noticed.
    Please help

    Viewing 0 reply threads
    Author
    Replies
    • #928425

      The Value property, as the name indicates, contains the value of the control. You are comparing this value with True or False. That doesn’t make much sense. To find out whether a control has a non-blank value, you can use the IsNull function:

      If Not IsNull(Forms![Update_master-data-charges]!txt_Check_Dates) Then

      Note: if this code is in the module of Update_master-data-charges itself, you can use

      If Not IsNull(Me!txt_Check_Dates) Then

      • #928429

        Thanks, I actually changed it to lstbox and wrote
        If Not IsNull(Me!lst_Check_Dates.Column(0)) Then

        So your idea modified…TAHNKS

        I hope you proud of me:)))

        • #928431

          Glad you worked it out yourself. If the Bound Column property of the list box is 1, you can omit the reference to Column(0) and simplify it to

          If Not IsNull(Me!lst_Check_Dates) Then

          • #928444

            I worked it out with your help but I twiked it.
            I will try bound the column (the cleaner the better, right?)
            THANKS so much

            • #928448

              This is doesn’t have to be answered, just curious…

              My lstbox is unbounded
              Row Source type is a Table/Query
              Row Sourse is a qry_App
              Bound Column 1

              However without Column(0) refferences it wouldn’t work the code we discussed or I am missing something. Query has 1 column with 1 date only always…or should I change to Bound Column 0
              (if it counts from 0)…THANKS

            • #928453

              The Bound Column property starts counting at 1 (1 = first column, etc.). The Column(n) property starts counting at 0 (0 = first column, etc.). The Bound Column specifies which column corresponds to the Value property of the list box. Since Value is the default property, Me!lst_Check_Dates is equivalent to Me!lst_Check_Dates.Value.

              So IsNull(Me!lst_Check_Dates) should be equivalent to IsNull(Me!lst_Check_Dates.Column(0))

    Viewing 0 reply threads
    Reply To: Value gets missed (Access97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: