Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2014-08-12
Medium Priority
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 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 1000 total points
ID: 40256282
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 40

Expert Comment

ID: 40256726
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

ID: 40267683
Thank you for your assistance with this question.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

810 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