Results 1 to 4 of 4
  1. #1
    fishhead is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2015
    Posts
    167

    Date field is null

    Hi can someone suggest how to write an "if" stmt that will run a command if a date field is empty (null)?

    so far what i'm using is :



    ifForms![fWireCreate]![fWireAPUnpaid].Form![WireDate] =null
    runmacro mwires.pymt

    I'm having difficulty if [wiredate] is empty, any ideas?

    thanks in advance.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Either:

    If IsNull(Forms![fWireCreate]![fWireAPUnpaid].Form![WireDate])

    Or

    If
    Forms![fWireCreate]![fWireAPUnpaid].Form![WireDate] Is Null
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    To elaborate on the response, nothing can be compared to Null
    ifForms![fWireCreate]![fWireAPUnpaid].Form![WireDate] =null

    Nothing is equal to, less than, greater than, not equal to, etc. - Null

    IsNull is for typically for vba; Is Null for sql. One of those should work, but the one you need isn't obvious from your post.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Assuming that the Control is on the same Form where the code is being executed...to validate whether a Control is populated or not, the Control to use is the Form's BeforeUpdate event. If you try doing it with an event tied to the Control, and the user simply doesn't enter the Control, your validation will be defeated...which is to say it'll never be executed. The code would be something like this:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
      If IsNull(Me.WireDate) Then
       'Do your code here
       End If
    End Sub
    If your situation is different...as @Micron suggested, you need to let us know what your scenario is, in plain language, as it isn't clear from your post.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 06-15-2018, 09:48 AM
  2. Replies: 2
    Last Post: 09-23-2014, 11:32 AM
  3. date field in subform not becoming null
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 04-03-2014, 07:26 PM
  4. Null alternative for Date/Time field
    By tylerg11 in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 04:04 PM
  5. Passing a NULL value to a date field
    By lman in forum Queries
    Replies: 2
    Last Post: 02-22-2011, 02:20 PM

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