• Checking for an Empty Field (A2K SR1)

    Author
    Topic
    #360575

    I have a form that contains a button that, when pressed, populates a bound number field with an automatically incremented number. However, to avoid overwriting an existing record, I would like to disable the button when it’s number field is already populated by a previously generated number (i.e., the button should work only when the number field is empty). What’s the best way to check for an empty number field on a form? I’ve set the default value for the number field to zero, allowing the button to work only when the number field contains a zero. Is there a way I can do this using the Null function? I’d prefer not to assign a default value to the field because, since the field is populated only by pressing the button and not by manually entering a number, it’s not necessary . Thanks for the help.

    Viewing 0 reply threads
    Author
    Replies
    • #543297

      If IsNull(Me![yourNumberfield]) Then
      ‘add your code here to populate with an incremented number
      End If

      If the Number field is not Null, the code will not execute. You can put an Else clause into the statement, if you want to take another action when the Number field is previously populated.

      • #543303

        Thomas,

        Thank you! An easy, elegant solution that completely solved my problem.

    Viewing 0 reply threads
    Reply To: Checking for an Empty Field (A2K SR1)

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

    Your information: