Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

HOW DO I USE A TIMER IN  ACCESS?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michelle - 29 Jul 2005 06:08 GMT
I am using access 2000 and trying to create a database to record and track
time spent on jobs to eventually use in payroll.
I have 2 command buttons in the form - one for logon, the other logoff.
I need to be able to record the time on and off when these buttons are
clicked by the employee but am not sure how to do it as I am really only a
beginner with some parts of access
fredg - 29 Jul 2005 08:06 GMT
> I am using access 2000 and trying to create a database to record and track
> time spent on jobs to eventually use in payroll.
> I have 2 command buttons in the form - one for logon, the other logoff.
> I need to be able to record the time on and off when these buttons are
> clicked by the employee but am not sure how to do it as I am really only a
> beginner with some parts of access

Add a table with 3 fields to the database.
LogID  AutoNumber, Indexed No duplicates, Prime Key
TimeLogOn .. DateTime datatype
TimeLogOff  .. DateTime datetype
Name the table tblLogTimes

Set the format property of each to
General Date

Add a Command Button to the form.
Name it cmdLogOn
Set it's Caption to "Log On"

Add another Command Button to the form.
Name it cmdLogOff
Set it's Caption to "Log Off"
Make this button Not Visible.

Open the Form's Code window (click View + Code).
Up in the Code's Declaration section, write:
Option Explicit
Dim dteLogOn as Date
===========

Code the cmdLogOn command button click event:

dteLogOn = Now
cmdLogOff.Visible = True
[AControl].SetFocus
cmdLogOn.Visible = False

Code the cmdLogOff Command Button click event:

Dim strSQL As String
strSQL = "Insert into tblLogTimes (TimeLogOn, TimeLogOff) Values (#" &
dteLogOn & "#, #" & Now & "#);"
CurrentDb.Execute strSQL, dbFailOnError
CmdLogOn.Visible = True
[AControl].SetFocus
CmdLogOff.Visible = False

Note: Change [AControl] to whatever the name is of the next control
you wish to go to.

When opened, only the Log On button is visible. When it is clicked, it
becomes not visible and the Log Off button is visible.

Signature

Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Michelle - 04 Aug 2005 07:09 GMT
I must  be having a bad week - thebrain definately not working.
Can you explain to me in normal english the control - assuming it is the
next page ie switchboard??

> > I am using access 2000 and trying to create a database to record and track
> > time spent on jobs to eventually use in payroll.
[quoted text clipped - 49 lines]
> When opened, only the Log On button is visible. When it is clicked, it
> becomes not visible and the Log Off button is visible.
fredg - 04 Aug 2005 17:33 GMT
> I must  be having a bad week - thebrain definately not working.
> Can you explain to me in normal english the control - assuming it is the
[quoted text clipped - 53 lines]
>> When opened, only the Log On button is visible. When it is clicked, it
>> becomes not visible and the Log Off button is visible.

Michelle,
I guess my brain is not working either.
What do you mean by this sentence:
"Can you explain to me in normal english the control - assuming it is
the next page ie switchboard??"

Remember... you know what you are talking about. You have to do a bit
more to explain what you want so others will understand you.
Signature

Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Michelle - 05 Aug 2005 02:49 GMT
Sorry!

In reference to the code:
                                CmdLogOn.Visible = True
                                [AControl].SetFocus
                               CmdLogOff.Visible = False

                                Note: Change [AControl] to whatever the
name is of the                next control you wish to go to.

I am not sure what the [AControl] is.  My knowledge of Access is pretty
limited - i know the basics and can get teh pages etc but the background
coding is confusing!

thanks

> > I must  be having a bad week - thebrain definately not working.
> > Can you explain to me in normal english the control - a ssuming it is the
[quoted text clipped - 62 lines]
> Remember... you know what you are talking about. You have to do a bit
> more to explain what you want so others will understand you.
fredg - 05 Aug 2005 04:40 GMT
> Sorry!
>
[quoted text clipped - 78 lines]
>> Remember... you know what you are talking about. You have to do a bit
>> more to explain what you want so others will understand you.

OK. Now I understand. Remember, I can only give you generic code as I
don't know what the actual control names are on your form.

[AControl] is any control you want to move focus to on your form.
Let's say the next control on your form you wish to go to is the
[LastName] control. You would then write:
CmdLogOn.Visible = True
[LastName].SetFocus
CmdLogOff.Visible = False

The command button cmdLogOn would be Visible, the [LastName] would
have focus and be ready for data entry, and the command button
cmdLogOff would become not visible.

The reason is that you cannot make a control not visible while it has
the focus.  Because this code is written when the LogOff button has
been clicked, it has the focus. You must first move to another
control. Any control is fine. Then you can make the LogOff Command
button not visible.

I hope this helps.
Signature

Fred
Please only reply to this newsgroup.
I do not reply to personal email.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.