Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Date Function Not Working
Stephen Fugowski 
    
34 days ago
The date function (date()) is no longer working in my VBA code. Every time I keyin date() it drops the parentheses and I get an error message that says the field cannot be found.  I didn't change the version of ACCESS and I didn't add or delete any other code. Could it be that my Windows version was updated? The ACCESS Database is running on a split database on a LAN.
Donald Blackwell  @Reply  
       
34 days ago
Access usually drops the parenthesis from the Date function. What is the rest of the line it's indicating?
Richard Rost  @Reply  
          
34 days ago
Yeah, let's see it. Screen shots please. If you type in:

D = Date

That should be a valid command.

A Windows or Office Update shouldn't affect this.
Stephen Fugowski OP  @Reply  
    
32 days ago
Right now I am on my home computer and it is working ok. But when I went to my work computer, that is where I got the error. So, when I go to my work computer tomorrow i will take the code that works at home and replace the code on the work computer to see if that fixes it. BTW, all of my work in ACCESS is volunteer work at a food pantry (Daystar Hope Center) in Dade City. If it is not fixed at work, I will send the screen shots when I get home. Our ACCESS DB is on a LAN and we are not allowed to go on the internet.
Richard Rost  @Reply  
          
32 days ago
You can always take pics of the screen with your phone... if that's allowed. I don't want to get you in trouble, but most problems are easier to troubleshoot if we can SEE what's going on.
Stephen Fugowski OP  @Reply  
    
32 days ago
I will find out if it's allowed.
Stephen Fugowski OP  @Reply  
    
30 days ago

Stephen Fugowski OP  @Reply  
    
30 days ago
I brought the database home and duplicated the error. The screen shot is above.
Richard Rost  @Reply  
          
29 days ago
Okay, which line is actually throwing the error? The problem line should highlight in yellow when the error occurs. That red line is just showing me where you set the break point, which is meaningless here.

Double check that you don't have a field or control on the form named Date. That can cause this exact issue because Access will try to treat Date as a field instead of the built-in function.

Date() is the function
[Date] would be a form field

Ideally you'd want:

Dim D as Date
D = Date()
MsgBox D


I recreated your code exactly as posted and it runs fine here. Using a Variant works, although technically you'd want D declared as a Date. Either way, that assignment is valid. My guess is you've got something on the form named Date and it's creating a naming conflict.
Stephen Fugowski OP  @Reply  
    
29 days ago
When I keyed in the line that says D = Date() it dropped the parentheses and when I debugged the code that is where  that line gave me the error. I could not find any where I use "Date" in the code, so I decided to check the structure of the Client table and sure enough, the person who developed the database did not know that you cannot use reserved words as fields in a table, because there was a field named "Date" in the client table. I changed the name of the field, but that did not work either. I still got the same error. I used the function Date() in other code in the database and it did not drop the parentheses. When did ACCESS start dropping the parentheses?
Richard Rost  @Reply  
          
29 days ago
Yeah, it's been doing that for a while now. Now, even though you change the name of the field at the table level, you might have a form control that still has the old name, because changing the name of the table doesn't change the name of the control on the form. Look for a text box on the form named "date".
Stephen Fugowski OP  @Reply  
    
29 days ago
No text box on the form named "date". I changed the code you suggested, but without the "D = Date" like this"

Private Sub Form_Load()

Dim D As Date
MsgBox D
........

End Sub

and the MsgBox displayed "= "12:00:00 AM"
Richard Rost  @Reply  
          
29 days ago
Yeah, that's weird. It should be returning a date. Let me see screenshots of everything in design view:
- Your code
- Your form
- The control names
The more you can show me, the better chance I have of fixing it.
Stephen Fugowski OP  @Reply  
    
28 days ago

Stephen Fugowski OP  @Reply  
    
28 days ago
None of the form fields are the date function.
Richard Rost  @Reply  
          
28 days ago
Alright, try doing the exact same thing in a brand-new blank database. Create a form, put a button on it, and stick just those two lines of code in there. That will tell us if it's a setting on your system or if it's that specific database.
Stephen Fugowski OP  @Reply  
    
28 days ago
Here is more stuff on the "Date Function not working" problem. If you go back to the original problem where I have to keyin the Startdate and Enddate twice maybe this will help. I think I read somewhere there is a way where you don't have to use parameters. Do you know anything about that? I think it involves creating another form that  uses unbound text boxes.
Stephen Fugowski OP  @Reply  
    
28 days ago
Is there some wa I can send you a Word doccument?
Stephen Fugowski OP  @Reply  
    
28 days ago

Stephen Fugowski OP  @Reply  
    
28 days ago

Stephen Fugowski OP  @Reply  
    
28 days ago

Donald Blackwell  @Reply  
       
28 days ago
Stephen, you haven't assigned a value to D yet. You Dim'd it, but it has not value, that's is why it reads 12:00 am because it is equal to zero.

In order to put the current date, you'd need:

Private Sub Form_Load()

Dim D as Date
D = Date
MsgBox D

End Sub


When I do this, I get a message box that pops up with the current date, i.e. 2026-02-14

You can also use a form field to enter a date into either by typing or using the Date Picker
Richard Rost  @Reply  
          
28 days ago
Donald excellent catch. How did I miss that? Sometimes I miss the simplest things. It's different when you're reading it on the screen versus when you're doing it and you're typing it in yourself.
Richard Rost  @Reply  
          
28 days ago
Donald I think I just missed it also because in his earlier example way at the beginning of the thread, he did set D equal to date. He did declare it and then set the value, so it's just in that last example he didn't do that.
Donald Blackwell  @Reply  
       
28 days ago
Yeah, I noticed that too Richard I've done that too, where I'm trying to correct one problem and introduce another that hides the first.

Stephen as a side note, in the design view of your "DayStar Client" form, I notice that there is a little "flag" on the "FirstVisit" control. You might want to check that out and see if it's the control name or the control source throwing the warning
Darrin Harris  @Reply  
     
28 days ago
Hello All

First of all the first image I noticed First visit has a problem, I don’t think that’s the issue but the error say Can't find the FIELD 'Date' referred to in your expression

This tells me that there is a field problem, I recreated the error by adding a Date field to the form
then I removed it from the form and change its name at the table level to MyDate, and got the same error message 2465?

The fix is to remove the table from the form, then save close open and add the table back.

This can be a problem, as there could be other things that may have to be done,  we really need to see table query and the form properties and field list to see what’s going on.

Hope this helps
Stephen Fugowski OP  @Reply  
    
27 days ago
Oh, the magic of ACCESS! I made a couple of changes to a couple of queries and VOILA!, everything is working right. No more keying in STARTDATE and ENDDATE twice, only once. Thanks to all those who helped. It cleared a few cobwebs in my 75 years old brain. I had another query that uses STARTDATE and ENDDATE that worked just fine. So I used it as a starting point.
Add a Reply Upload an Image
Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/14/2026 4:28:16 AM. PLT: 1s