Results 1 to 3 of 3
  1. #1
    StuartR is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Scotland
    Posts
    46

    refering to a field on a form

    I am sure this will be easy but ....

    I have a form, with a button that triggers a Private Sub Form_AfterUpdate()

    I want to put in a bit of code that determines if an email field is blank, and therefore performs one action or another. The code (and versions of it that I have tried) is as follows, but I am getting errors such as Object Required, object not defined etc.

    Code:
    Private Sub Form_AfterUpdate()
    
    If [email 1] Is Null Then
    MsgBox ("No email address has been entered")
       'do something here
    else
       'do something else
    end if
    What is wrong with my "If" line ???



    Cheers

    Stuart

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    is [email 1] the name of the text box? (its best not to put spaces in names) you can always ad ME. to the front of the control too. if me.[email 1] ...

    and the test for null on a form is:
    If isNull([email 1]) Then

    in a query it is: [FIELD] is null

  3. #3
    StuartR is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Scotland
    Posts
    46
    Thanks Ranman

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 06-19-2015, 02:19 AM
  2. Replies: 1
    Last Post: 06-21-2012, 09:38 AM
  3. Replies: 1
    Last Post: 05-23-2012, 11:45 AM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Replies: 3
    Last Post: 06-03-2009, 07:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums