MS Access code update that will allow identifation of blank or null values during import

Posted on 2014-08-12
Last Modified: 2014-08-18
Hello Experts.  I need your help to change the below Function code to also allow for null or blank values.  Currently the code updates chk1 to True when there is a date, but does not update chk1 to True when null or blank.

Function chk1(A As String) As Boolean
'Check date
Dim i As Integer, l As Integer, c As String
A = Trim(A) 'remove possible spaces
chk1 = False
If IsDate(A) Then chk1 = True
If IsNull(A) Then chk1 = True    'I inserted this line, but it does not work

End Function
Question by:dhemple
    LVL 56

    Accepted Solution

    Strings can't accept a null value (only a zero-length string or an actual string), so:

    Function chk1(varInputDate As Variant) As Boolean

      'Check date
       If IsNull(varInputDate ) or IsDate(varInputDate) then Chk1 = True

    End Function
    LVL 33

    Expert Comment

    Are you really intending to change the value of A in the calling procedure?

    By default, arguments are passed by reference (ByRef) that means a pointer is passed rather than a copy of the variable.  So, your code when it changes A, is changing A in the calling procedure.

    Author Closing Comment

    Thank you for your assistance with this question.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now