PC Review


Reply
Thread Tools Rate Thread

Clocking in (and out), and how can I do it?

 
 
anubislg@gmail.com
Guest
Posts: n/a
 
      16th Aug 2006
Hello!

I'm rather new to VBA, and Access in whole, so please bear with me.
I'm currently trying to create a form that will automatically fill in
the current time when a user inputs data into a specific text box. In
short, I wish to make a form that when an employee enters there
employee number, it will log the current time.
Now, I've got it to where when I input the employee number into the
text box, the time field will automatically update with the current
time...but the number one main problem I've ran into, is when you
re-open the form, the time updates to the current time that you opened
the form, not the first time of clock-in!

Current code that I'm using is:
In the Control Source of the "Start Time";
=IIf(IsNull([Clock In]),Null,IIf(IsNull([Main]![Topaz Start
Time]),Now([Main]![Topaz Start Time]),[Main]![Topaz Start Time])

Now, this code (at least to me) should work. In essance, it should
check to see if [Clock In] is null, if it is, then enter no
information, if it isn't null though, then check to see if the record
[Main]![Topaz Start Time] is null, if it is, then fill in the record
with the current time, if the record isn't null, then return the
record. But it seams that I've gone astray somewhere with this
formula. Could anyone offer me some hints? Thank you all!

-Matthew

 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      16th Aug 2006
On 15 Aug 2006 17:13:21 -0700, (E-Mail Removed) wrote:


>Current code that I'm using is:
>In the Control Source of the "Start Time";
>=IIf(IsNull([Clock In]),Null,IIf(IsNull([Main]![Topaz Start
>Time]),Now([Main]![Topaz Start Time]),[Main]![Topaz Start Time])
>
>Now, this code (at least to me) should work. In essance, it should
>check to see if [Clock In] is null, if it is, then enter no
>information, if it isn't null though, then check to see if the record
>[Main]![Topaz Start Time] is null, if it is, then fill in the record
>with the current time, if the record isn't null, then return the
>record. But it seams that I've gone astray somewhere with this
>formula. Could anyone offer me some hints? Thank you all!
>
>-Matthew


For one thing, it's far more complex than it need be. You can use the
NZ() function instead. For another, the Now() function returns the
system clock time - it doesn't take any arguments (you're trying to
pass it the form reference). For yet another, you don't need to - and
shouldn't - use the form name in this way; if the code is on form Main
you need only use the control name, or you can use Me![Topaz Start
Time], or you can use [Forms]![Main]![Topaz Start Time] - but not just
[Main]!...

Finally, this code will DISPLAY a time value, once it gets corrected -
but it will not cause that value to be stored in any table field. The
Control Source is a calculated expression, not bound to any table
field.

So: what *are* the relevant fields in your Table, and to which form
controls are those fields bound (as Control SOurce)?

John W. Vinson[MVP]
 
Reply With Quote
 
AnubisLG
Guest
Posts: n/a
 
      16th Aug 2006
First of all, thank you John for your help! As I said before, I'm
still quite the novice at Access. I suppose I should have been a bit
more definative about what I was calling out in my scrap heap of random
code!

=IIf(IsNull([Clock In]),Null,IIf(IsNull([Main]![Topaz Start
Time]),Now([Main]![Topaz Start Time]),[Main]![Topaz Start Time])

"[Main]![Topaz Start Time]" Is supposed to be the reference to the
table (Main) and field (Topaz Start Time). I had just taken a wild
stab that I could manipulate the data in the table via this method.
"Clock In" is the name of the form control for which I wish to display
the time inputed to the table, and is also the control for which I
wrote the original code for (and inserted into the control source).

So I suppose my questions now are;
1. Can I maniupulate table data using a form control's control source,
and if not, then how could I go about doing it? Did I just use
incorrect syntax for calling to the table?
2. I'll definatly have to do more research into the NZ() function you
told me about.

Thank you again for your aid!
-Matthew

John Vinson wrote:
>
> For one thing, it's far more complex than it need be. You can use the
> NZ() function instead. For another, the Now() function returns the
> system clock time - it doesn't take any arguments (you're trying to
> pass it the form reference). For yet another, you don't need to - and
> shouldn't - use the form name in this way; if the code is on form Main
> you need only use the control name, or you can use Me![Topaz Start
> Time], or you can use [Forms]![Main]![Topaz Start Time] - but not just
> [Main]!...
>
> Finally, this code will DISPLAY a time value, once it gets corrected -
> but it will not cause that value to be stored in any table field. The
> Control Source is a calculated expression, not bound to any table
> field.
>
> So: what *are* the relevant fields in your Table, and to which form
> controls are those fields bound (as Control SOurce)?
>
> John W. Vinson[MVP]


 
Reply With Quote
 
AnubisLG
Guest
Posts: n/a
 
      16th Aug 2006
Correction:
"Clock In" is the control which a user enters there employee number.
The code I wrote was ~not~ placed into "Clock In", but rather a control
called "Start Time." Just wanted to clarify that. Burning midnight
oil is taking it's tole.
-Matthew

AnubisLG wrote:
> "Clock In" is the name of the form control for which I wish to display
> the time inputed to the table, and is also the control for which I
> wrote the original code for (and inserted into the control source).


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Over clocking? itsme General Discussion 11 19th Sep 2005 07:15 PM
Over-clocking... =?Utf-8?B?Q2hyaXM=?= Windows XP General 11 18th Apr 2005 05:57 AM
clocking ah Microsoft Excel Misc 1 4th Aug 2004 02:37 AM
Over clocking =?Utf-8?B?Vmlubmll?= Windows XP Games 2 23rd Dec 2003 06:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:26 PM.