473,486 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Set Field to Equal Now()

124 New Member
I have the following line of code in a sub in which I want to set a date/time field to equal the current date/time when a particular sub is executed:

Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute "UPDATE StdDegReq SET LastEvaluted = Now() WHERE StdDegReqId = " & lngStdDegReqId
  2.  
I cannot get this to work. I've tried the following, each giving me either a syntax or too few parameters error:

LastEvaluated = Now
LastEvaluated = " & Now() & " WHERE...
LastEvaluated = #" & Now() & "# WHERE...
LastEvaluated = #" & Now & "# WHERE...

I thought this would be simple! How do I write this?
Jun 7 '10 #1
4 2229
gershwyn
122 New Member
The code you posted has a typo: LastEvaluted instead of LastEvaluated. If that's how it is in your code, that's certainly the problem.

If that was just a mistake while posting your code, I would try assigning your SQL to a string variable, and use either the msgbox function or debug.print to see how it looks immediately before executing.
Jun 7 '10 #2
bullfrog83
124 New Member
@gershwyn
Sadly, it was a typo! I should have figured that since I kept typing evaluated wrong (forgetting the "a") when giving the different examples of what I tried in my post.
Jun 7 '10 #3
gershwyn
122 New Member
I do the same thing all the time - in fact, I assumed I had made the typo myself when I went to test your SQL. Glad it was an easy fix for you.
Jun 7 '10 #4
OldBirdman
675 Contributor
If the project has the option "Require Variable Declaration" set, then each module will have "Options Explicit". This means that Access will require a declaration of the variable.
I note that you use "Camel" names (mix of upper and lower case). When typing code, if you always type lower case, Access will correct to the declared form on completion of the statement. It is easy to see if you have a typo.
If you fail to note that the name was not modified, Access raises an error if the statement is executed.
I haven't seen any reason not to do this.
Jun 7 '10 #5

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

Similar topics

2
9448
by: Phil Powell | last post by:
I have a mySQL database table with a column field datatype of datetime that I set up in the original create table statement like this: create table nnet_usermetadata ( .... nnet_record_entered...
5
9905
by: JeffFinnan | last post by:
Is there a way to have a text input field equal some variable value so that it changes if that variable changes? It does not have to by dynamic. <INPUT TYPE="TEXT" NAME="hW" size="4" value=some...
4
4084
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
2
2267
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
2
6865
by: abprules | last post by:
Is there a way that I can create a "Last Updated by" field in MS Access. I know how to do the Date Last Updated but can't seem to find out how to record the user who last updated the info. ...
3
3345
by: C8H10N4O2 | last post by:
How would I set one fields value equal to something based on another table in a form. For instance, could I implement VB on enter in a form's combo box to set a number field equal to one or zero in...
5
2284
by: Mangler | last post by:
I need to make a text field equal to the entered value. Example: First time to the page nothing will show up in the field because nothing was entered. I enter a value and submit the form. The...
1
1573
by: indhu | last post by:
Hi all, I want 2 know, how to populate using 2 combo box to populate other field. right now am using click event of combo to populate the other field but i want to select both combo1 and combo2 ...
8
10977
beacon
by: beacon | last post by:
Hi everybody, I'm having a terrible time trying to accomplish what I thought would be extremely easy. I have three date fields on a form (DischargeDate, ReceivedDate, and AuditedDate) and I'm...
0
7100
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
6964
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
7175
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
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.