I would have thought that this operation would be simple: - Me.IUR_DATE.Value = DATE()
but the parentheses simply refuse to remain.
(Although I've been a programmer for 20 years, I'm finding Access really murky. Is it just me? That would be depressing...)
Anyway, here's the context: - Private Sub CLEAR_IUR_1_Click()
-
On Error GoTo Err_CLEAR_IUR_1_Click
-
-
Dim ctl As Control
-
-
For Each ctl In Me.Controls
-
If ctl.Tag = "Clear" Then
-
ctl.Value = Null
-
End If
-
Next
-
-
Me.IUR_DATE.Value = DATE
-
-
Exit_CLEAR_IUR_1_Click:
-
Exit Sub
-
-
Err_CLEAR_IUR_1_Click:
-
MsgBox Err.Description
-
Resume Exit_CLEAR_IUR_1_Click
What am I not understanding about this syntax?
Thanks!
Sue,
It looks to me very much like some other object is defined, and available to your database, with a name of DATE. If it were being recognised as the Date() function (from the VBA library) then only the D would be capitalised. Do you know how to use the Object Browser (See Debugging in VBA) to find what is declared where?
As Linq intimated earlier, your code has no obvious bug in it. What you have should normally work.
13 12324
Yes, Access VBA will remove the parens in some instances, but it doesn't affect the code, it should still work.
IMHO, Access VBA is no 'murkier' than any other language; they all have their quirks! The important thing to understand, especially for programmers who have worked previously in straight Visual Basic, is that VBA is a different language. Many things are the same, but many functions, even those with similar or even identical names, perform differently.
Linq ;0)>
I've never worked in "straight Visual Basic"--my time was spent mostly with Ada.
Be that as it may, the very reason I'm posting the question is because it DOESN'T work. My date field does not get set to today.
Are you trying to make the field and autodate feature? Where it will put the date in for you instead of someone one having to key in the date.
If that is the case all you need is in the properties for the text box (on your form) you are using put this in the default value field
Then you can actually sent the text box to not visible link it to your table and it will automatically save todays date to your table every time something is entered.
hope that helps
Not exactly. I need the field to be set when the user takes a specific action (clicks a little button that is on the form) rather than when there record is created.
NeoPa 32,556
Expert Mod 16PB
Sue,
It looks to me very much like some other object is defined, and available to your database, with a name of DATE. If it were being recognised as the Date() function (from the VBA library) then only the D would be capitalised. Do you know how to use the Object Browser (See Debugging in VBA) to find what is declared where?
As Linq intimated earlier, your code has no obvious bug in it. What you have should normally work.
@NeoPa
That makes real sense. I'll look around, but on the good chance that that is actually the case, I know that I'll not want to mess that object, so how can I specify here that what I want is the Date from the VBA library and not any other?
but on the good chance that that is actually the case, I know that I'll not want to mess that object, so how can I specify here that what I want is the Date from the VBA library and not any other?
You can't! You simply have to change the name of the object to something other than Date!
Linq ;0)> @missinglinq
Wait, what?? You mean the language doesn't support overloaded names and the ability to specify which you want?
NeoPa 32,556
Expert Mod 16PB
It does to a certain extent, but Date is a fundamental part of the basic setup. It is always recommended very strongly not to overload such items due to the confusion they will necessarily cause.
In this case, it is possible, but I repeat not a recommended solution, to use VBA.Date.
What are the pitfalls, in this case, of using specific notation to access VBA's date function?
NeoPa 32,556
Expert Mod 16PB
None, as such Sue.
The pitfalls generally are associated with reusing common names in a project. Reading and understanding what is going on is always likely to be harder when there is any possibility of ambiguity. Using VBA.Date() is not ambiguous, but having some object called DATE is likely to be. Does that clarify?
I totally agree, but since I'm just maintaining this databse (and part-time at that!) I just wanted to know how I could specify that I wanted to access the system date and not whatever function some previous developer overloaded that name with.
Thanks to you, I can now do that!
(This site is wonderful!)
NeoPa 32,556
Expert Mod 16PB
It's always pleasant to read such responses. You're welcome of course :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: peashoe |
last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an
exact date format in the text field (txtDDate). My problem is I need
some javascript that sets an alert that does not allow them...
|
by: Lumpierbritches |
last post by:
Can this be done in access by a lay person? Also, are there any tutorials for
this type of addition to your applications?
I'm trying to use a calendar control to set a date in the future for a to...
|
by: Anna |
last post by:
I am an extreme newbie to Access and need help setting a default date
on a form.
The situation is:
I have a field called date_received which is set to default to today's
date.
I have another...
|
by: Dixie |
last post by:
Can I set the Format property in a date/time field in code?
Can I set the Input Mask in a date/time field in code?
Can I set the Format of a Yes/No field to Checkbox in code?
I am working on...
|
by: k.roberts |
last post by:
I'm not sure if this is possible or even practical to do, but I have a
database which logs customer enquiries and has a field for the status
of the enquiry i.e. Received, Approved, Job start, Job...
|
by: walterbyrd |
last post by:
My MySQL table has a field that is set as type "date." I need to get
today's date, and insert it into that field. The default for that MySQL
field is 2006-00-00.
I know about the date()...
|
by: LostBoy |
last post by:
Hello,
I have been giving a big task to add some additional features to the Access DB at work. I am not the one who originally created the DB, which makes it harder. I am familiar with access but...
|
by: Techhead |
last post by:
I have a date/time field with a sql format of "datetime" The actual
date/time data format is MM/DD/YYYY^hh:mm:ss:pm or "1/25/2007
12:00:16 AM" Both the date and time are combined on the same field...
|
by: Luqman |
last post by:
Hi,
Any Idea how to Display Todays Date in DetailView Template Field while Inserting ?
For example: When I click on New Button of DetailView Control, I need to display Today's Date in a...
|
by: Ciara9 |
last post by:
I am having problems trying to update a field in a database using a field in a form. I currently have two fields, Today and Tomorrow in a table named Date. The Today field automatically defaults to...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |