473,569 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Time()

I have a form that is bound on a table. The form has a text box that
has
=Time() and an Add button. How can I update the time or make it the
current time before adding a record on the table via the form? I tried
putting Time() on the Add event's code before the "DoCmd.GoToReco rd ,
, acNewRec" line but, it still doesn't pick up the current time. It
only updated the text box after the record has been added.

I tried using the Form's "On Timer" & "Time Interval" properties, the
text box gets updated in real time but, it won't work for me because
everytime I n=navigate through the records on the form (back &
forward) the time on the table changes to the current real time. Also,
I have an "Update" button. When I go back to a particular record, to
update it, the "Update" button picks up the real time on the text box.

Sp I figured the best thing for me is to not set the "On Timer" &
"Time Interval" properties. Instead, simply update the time text box
automatically before I add a record. Also can I make it so that the
original time remains the same on an update. Any ideas will be
appreciated. Thank you in advance.

Paul
Nov 13 '05 #1
4 1543
Are you just trying to show the time on the form?
Or do you want to record the time in a field in your table?

If you wish to record the time, use the BeforeUpdate event procedure of the
form:

Private Sub Form_BeforeUpda te(Cancel As Integer)
Me.[NameOfYourTimeF ieldHere] = Time()
End Sub

If you want the date and time, use = Now()

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul" <pc*******@yaho o.com> wrote in message
news:78******** *************** **@posting.goog le.com...
I have a form that is bound on a table. The form has a text box that
has
=Time() and an Add button. How can I update the time or make it the
current time before adding a record on the table via the form? I tried
putting Time() on the Add event's code before the "DoCmd.GoToReco rd ,
, acNewRec" line but, it still doesn't pick up the current time. It
only updated the text box after the record has been added.

I tried using the Form's "On Timer" & "Time Interval" properties, the
text box gets updated in real time but, it won't work for me because
everytime I n=navigate through the records on the form (back &
forward) the time on the table changes to the current real time. Also,
I have an "Update" button. When I go back to a particular record, to
update it, the "Update" button picks up the real time on the text box.

Sp I figured the best thing for me is to not set the "On Timer" &
"Time Interval" properties. Instead, simply update the time text box
automatically before I add a record. Also can I make it so that the
original time remains the same on an update. Any ideas will be
appreciated. Thank you in advance.

Paul

Nov 13 '05 #2
Also, to keep the original time during an update, change Allen's code to
something like:
Private Sub Form_BeforeUpda te(Cancel As Integer)
If IsNull(Me.[NameOfYourTimeF ieldHere]) Then
Me.[NameOfYourTimeF ieldHere] = Time()
End If
End Sub
--
-----------
Reggie
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:41******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Are you just trying to show the time on the form?
Or do you want to record the time in a field in your table?

If you wish to record the time, use the BeforeUpdate event procedure of
the form:

Private Sub Form_BeforeUpda te(Cancel As Integer)
Me.[NameOfYourTimeF ieldHere] = Time()
End Sub

If you want the date and time, use = Now()

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul" <pc*******@yaho o.com> wrote in message
news:78******** *************** **@posting.goog le.com...
I have a form that is bound on a table. The form has a text box that
has
=Time() and an Add button. How can I update the time or make it the
current time before adding a record on the table via the form? I tried
putting Time() on the Add event's code before the "DoCmd.GoToReco rd ,
, acNewRec" line but, it still doesn't pick up the current time. It
only updated the text box after the record has been added.

I tried using the Form's "On Timer" & "Time Interval" properties, the
text box gets updated in real time but, it won't work for me because
everytime I n=navigate through the records on the form (back &
forward) the time on the table changes to the current real time. Also,
I have an "Update" button. When I go back to a particular record, to
update it, the "Update" button picks up the real time on the text box.

Sp I figured the best thing for me is to not set the "On Timer" &
"Time Interval" properties. Instead, simply update the time text box
automatically before I add a record. Also can I make it so that the
original time remains the same on an update. Any ideas will be
appreciated. Thank you in advance.

Paul


Nov 13 '05 #3
Thanks for the post. I tried the code but, it still doesn't work. It
did solve the problem where the time changes when I do updates.
However, it still not picking up the current time when I "Add".

The text box has a default value of =Time(). Before I click the "Add"
button, I want to pick the current time and record it on the record
source. Any other suggestions?

"Reggie" <NoSpam_chief12 3101@NoSpam_yah oo.com> wrote in message news:<6b******* *************@c omcast.com>...
Also, to keep the original time during an update, change Allen's code to
something like:
Private Sub Form_BeforeUpda te(Cancel As Integer)
If IsNull(Me.[NameOfYourTimeF ieldHere]) Then
Me.[NameOfYourTimeF ieldHere] = Time()
End If
End Sub
--
-----------
Reggie
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:41******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Are you just trying to show the time on the form?
Or do you want to record the time in a field in your table?

If you wish to record the time, use the BeforeUpdate event procedure of
the form:

Private Sub Form_BeforeUpda te(Cancel As Integer)
Me.[NameOfYourTimeF ieldHere] = Time()
End Sub

If you want the date and time, use = Now()

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul" <pc*******@yaho o.com> wrote in message
news:78******** *************** **@posting.goog le.com...
I have a form that is bound on a table. The form has a text box that
has
=Time() and an Add button. How can I update the time or make it the
current time before adding a record on the table via the form? I tried
putting Time() on the Add event's code before the "DoCmd.GoToReco rd ,
, acNewRec" line but, it still doesn't pick up the current time. It
only updated the text box after the record has been added.

I tried using the Form's "On Timer" & "Time Interval" properties, the
text box gets updated in real time but, it won't work for me because
everytime I n=navigate through the records on the form (back &
forward) the time on the table changes to the current real time. Also,
I have an "Update" button. When I go back to a particular record, to
update it, the "Update" button picks up the real time on the text box.

Sp I figured the best thing for me is to not set the "On Timer" &
"Time Interval" properties. Instead, simply update the time text box
automatically before I add a record. Also can I make it so that the
original time remains the same on an update. Any ideas will be
appreciated. Thank you in advance.

Paul


Nov 13 '05 #4
I think I found a solution. I unbounded the [Time] text box on the
form. I set the "On Timer" & "Time Interval" back on this [Time] text
box so that it displays the real time on the form. I then set the
=Time() directly on the table under the default value (table design).
It worked like a charm.

If anybody still have another solution by making the changes on the
form, I'm still open for other suggestions.

Thanks for solving the my "update" problem part.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2744
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like storing products in
3
7818
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's the issue. I hope I've included all relevant information. On a form, I have a DateTimePicker with the following
3
2360
by: FRITSCH Vincent | last post by:
Hi, i need help on a query. I've this table : create table t ( customer number(5), time date, status varchar2(1)
5
2174
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows: Objectives The purpose of this assignment is to have you practice the design of object-oriented classes, including one or more of the following...
3
2430
by: stuart_white_ | last post by:
I've just upgraded from Python 2.3.3 to Python 2.4.2, and, although the new version of Python seems to be running correctly, I can't seem access the help from the interpreter. On Python 2.3.3 --------------- Python 2.3.3 (#51, Dec 18 2003, 20:22:39) on win32 Type "help", "copyright", "credits" or "license" for more information. >>>...
2
1798
by: Prophet | last post by:
Can someone help me troubleshoot this IISSTATE log ? I have tried to make sense out of it but with no luck I am currently running IIS5 on a Win 2k box. Hosting 3 web sites and runnning asp pages. One of the asp pages (confirmations.asp) is making the dllhost.exe process hog all the cpu for a while and the underlying application (the...
6
6425
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the Autoexec Macro looks like the way to go. Could someone please assist? Thank you very much! Mike
0
5542
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
6
2850
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
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 we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.