473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Auto fill date question...

Hi. I have created a form so a user can enter a serial number, device type, and so on for tracking inventory. I am able to get the date field to autofill with the current date. Just in case someone accidently types in something else, however, I want it to re-fill the field with the correct date. This is the VBA code I used for the form:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub WhenLastModified_Enter()
  4.  
  5. Me!WhenLastModified = Date
  6.  
  7. End Sub
  8.  
  9. Private Sub WhenLastModified_Exit()
  10.  
  11. If Not (Me!WhenLastModified = Date) Then
  12. Me!WhenLastModified = Date
  13. End If
  14.  
  15. End Sub
It makes sense to me, but of course computers don't speak plain English and I get this error message when I enter the field:

"Procedure declaration does not match description of event or procedure having the same name."

Any help on this would be much appreciated.

Thanks,
Josh
Aug 15 '11 #1
3 1806
patjones
931 Expert 512MB
Hi Josh,

Why not just lock that field so that the user cannot type anything in it? If you don't want to do that then we can look into why the VBA code isn't working, but I thought I'd suggest the simple fix first.

Pat
Aug 15 '11 #2
Hi Pat,

This fix works perfectly, I didn't even think of locking it. Thank you for the help!
Aug 15 '11 #3
NeoPa
32,556 Expert Mod 16PB
Specifically to explain the problem (although Pat's suggestion to lock the field, or even use a label instead, is a much more sensible approach anyway), this error message comes when an event procedure has specific parameters that it expects.

In this case the Exit event procedure should look like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub WhenLastModified_Exit(Cancel As Integer)
  2.     Blah blah blah
  3. End Sub
This can be achieved automatically by navigating to the code from the control's Exit property (or even from the VBA IDE window by selecting the control from the left-hand (Object) ComboBox and then Exit from the right-hand one (Procedure)).

PS. You really should check out When Posting (VBA or SQL) Code.
Aug 16 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Maurice Mertens | last post by:
Does anyone know how to get an auto-filling combobox on a form? When I add a combobox to a form I can set the DropDownStyle property to DropDownList. This will make the combobox auto-filling. But...
3
by: Maurice Mertens | last post by:
Hi all, In VB.NET you can set the DropDownStyle for a combobox to 'DropDown' or 'DropDownList'. When you set it to DropDownList, it supports auto-fill. But when you set it to 'DropDown', the...
1
by: ChuckDubya | last post by:
It's common in web browsers to have a text auto-fill function for personal information or passwords or whatnot. The flavor that I'm referring to is the kind that pops up as you're typing the word,...
2
by: Edwin Knoppert | last post by:
I would like to instruct a grid which autofill's the columns to exclude time or date from a date field when date or time is 0. Date and time can be stored in a date field, my grid shows for...
2
by: big_boy | last post by:
i am working with access 2000. i have a form that when you feel it out, it stores the information in the table for the form. am trying to write a auto fill query for it to automatically fill the rest...
2
by: Elainie | last post by:
I have been trying to auto fill fields with DLookup - but it doesn't seem to work..... can you help... I have a name field and I want the address to automatically fill in when the name field...
0
by: dd4611 | last post by:
Please, I need help in creating a macro to auto fill a range with beginning and ending date variables.
0
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on...
3
by: Steve67 | last post by:
I didn't see a search feature in these forums, so I couldn't look up this question and I am sure it is a common questions. I am trying to auto fill some information on an form. Here is what I have...
10
by: Charles Richmond | last post by:
Is there some parameter I can set via Javascript that will cause the browser to *not* auto-fill forms, regardless of the browser settings??? --...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.