Solved

How to assign a date read from an Access table to a variable in Access 2003 using VBA code?

Posted on 2013-11-04
2
548 Views
Last Modified: 2013-11-04
I am developing an Access 2003 application using an MDB type file.

I have a table named  importMonthlyChecks from which I read a record and want to assign its date value in format MM/DD/YY to a variable field.

The first value for the field BankName which is a TEXT field with a length of 53 in the table importMonthlyChecks appears as follows:

Starting in position  5 is the value "DATE" and
Starting in postion 11 is the date value "10/31/13".

    DATE  10/31/13
--------------------------------------

I use the followng VBA code:

ssql = "select * from importMonthlyChecks where   Left(Trim(bankname), 4) = 'DATE' "
rst.Open ssql, con, 2, 2
dateFile = Right(Trim(rst("bankname")), 8)

However, instead of retrieving the value 10/31/13 in the variable dataFile,
I get the value 12:00:00 AM in the variable dateFile?

Do you know how I can get the dateFile to be assigned the value "10/31/13" from the table
importMonthlyChecks?
0
Comment
Question by:zimmer9
2 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 39622189
What is the data type of your dateFile variable?

Also, why aren't you storing this date in a date field in your table?
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39622191
dateFile = Left(Trim(bankname), 4) & " " & format(Date(),"mm/dd/yy")
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

760 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

20 Experts available now in Live!

Get 1:1 Help Now