Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking for an Empty Field (A2K SR1)

    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.

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking for an Empty Field (A2K SR1)

    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.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking for an Empty Field (A2K SR1)

    Thomas,

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •