473,382 Members | 1,404 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,382 software developers and data experts.

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.GoToRecord ,
, 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 1532
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_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTimeFieldHere] = 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*******@yahoo.com> wrote in message
news:78*************************@posting.google.co m...
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.GoToRecord ,
, 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_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[NameOfYourTimeFieldHere]) Then
Me.[NameOfYourTimeFieldHere] = Time()
End If
End Sub
--
-----------
Reggie
"Allen Browne" <Al*********@SeeSig.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_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTimeFieldHere] = 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*******@yahoo.com> wrote in message
news:78*************************@posting.google.co m...
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.GoToRecord ,
, 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_chief123101@NoSpam_yahoo.com> wrote in message news:<6b********************@comcast.com>...
Also, to keep the original time during an update, change Allen's code to
something like:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[NameOfYourTimeFieldHere]) Then
Me.[NameOfYourTimeFieldHere] = Time()
End If
End Sub
--
-----------
Reggie
"Allen Browne" <Al*********@SeeSig.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_BeforeUpdate(Cancel As Integer)
Me.[NameOfYourTimeFieldHere] = 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*******@yahoo.com> wrote in message
news:78*************************@posting.google.co m...
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.GoToRecord ,
, 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
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...
3
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...
3
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
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:...
3
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...
2
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...
6
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...
0
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...
6
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();
1
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...
0
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.