Fill Data automaticly using a Timer() (1 Viewer)

HAMMAMABUARQOUB

Registered User.
Local time
Today, 13:38
Joined
Jul 29, 2009
Messages
75
Idea for Filling Data automaticly using a Timer()

Again,, back with a new tip for developers.. specially who use timers and automation ... and you will learn below that it can be used for monitoring and security...
this is the code:
Code:
Private Sub Form_Timer()
Me.s.Caption = Second(Time())
Me.m.Caption = Minute(Time)
Me.h.Caption = Hour(Time())
If Val(Me.m.Caption) = 5 Or Val(Me.s.Caption) = 59 Then
Me.Label3.Visible = Not Me.Label3.Visible
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO t1 ( Sec, [Min], Hr )SELECT Val(Forms!times!s.Caption) AS sss, Val([Forms]![times]![m].[Caption]) AS mmm, Val([Forms]![times]![h].[Caption]) AS hhh"
Else
Me.Label3.Visible = False
End If
End Sub
How to use:
simply.. create the table with the name t1 and sec, min, hr , and notes field or username field or inventory item or,, whatever
creat a form ,name it as here times
creat the labels,, s, m, and h .. and also remember lable3 for displaying the record added msg on the form just to inform the user instead of having to display the "you are about to....etct" default bu access action queries,,,note,, here helps the "setwarnings false " command,,,,
we are not done yet,,
past the code in the form..as it is here...note that it can be upgraded or updated or developed by anyone who wants more options,, like
controlling the time after which you wanna add records,, or even more,,
EXAMPLE INCLUDED...
bye bye!!!
tell me what you think.. any feedback is wellcomed
HAMMAM ABUARQOUB
 

Attachments

  • TimeStamp.zip
    34.3 KB · Views: 426
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:38
Joined
Jan 20, 2009
Messages
12,849
What is the practical application for this tip?

On each timer event it writes the hour, minute and second to labels on a form and then saves them as separate fields in some kind of log table.

The displayed time would be continuously wrong except for the moment when the Timer event triggered. Why one would want to break down a log time entry into three separate fields is a mystery to me.

It has an if statement to make a label display toggle when the minute is 5 or the second is 59. This is a rather bewildering construct. I haven't thought about it much but I would anticipate the state of this display would depend on the time when the form was loaded.

All up it seems a rather clumsy and unreliable implementation of very simple tasks. I suggest the best way to start upgrading it would be by deleting everything between Sub and End Sub.

Refer to this post about the need for extra smiles on this forum.
http://www.access-programmers.co.uk/forums/showthread.php?t=176728
 

ByteMyzer

AWF VIP
Local time
Today, 03:38
Joined
May 3, 2004
Messages
1,409
I suggest the best way to start upgrading it would be by deleting everything between Sub and End Sub.

Excellent suggestion, Galaxiom! I followed your suggestion, and it is MUCH cleaner, more practical code! ;)
 

HAMMAMABUARQOUB

Registered User.
Local time
Today, 13:38
Joined
Jul 29, 2009
Messages
75
its very simlpe,,, just need to tell you!
note that it can be upgraded or updated or developed by anyone who wants more options,, like
controlling the time after which you wanna add records,, or even more,,
in case anyone saw this sentence in the first place,,,all i mean it can be used as tracking realtime entries or changes as automatic log or change history in this particuler table or the other tables..in the comming days i wil post the idea of creating a log file and exporting it to txt outside..
anyway:
I suggest the best way to start upgrading it would be by deleting everything between Sub and End Sub.
Such mentality and way of judging other peoples ideas and work "even it is a simlple line of code" is realy unacceptable and makes it difficult to communicate and change ideas.. even if you think you want to "vomit" as a result of seeing them
i am sorry to say it but the suggestion you say is cleaner and more practical gives a very clear idea about the VIPs like yourself with this agressiveness and mockery of members even with "the vomit making posts"
... sir,, try to be polite,,,please..its a programmers community not a Bar!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:38
Joined
Jan 20, 2009
Messages
12,849
I'm genuinely sorry HAMMAMABUARQOUB.

However you have invited this kind of response by turning up here and immediately posting some very ordinary (at best) tips as though you are some kind of expert. This particular post went too far, not just because it was a poorly conceived solution to a non-problem.

The style of your post (eg "neverminds the name! ooooops!!hhh gotchou! be carful! the form name here is important") is inane. I don't know what kind of audience you mean to target but this kind of thing just wastes time and is explicitly discouraged.
http://www.access-programmers.co.uk/forums/showthread.php?t=170250

Your expressed intent to follow up this post with more related code rings alarm bells. What we don't need is the site being diluted by copious amounts of unsolicited dubious advice or stuff that is easily found from any of dozens of other sites.

Some members have made huge contributions and have earned our respect because we have come to trust their advice. I would suggest if you want to post tips then earn a bit of that respect first by answering some questions, gaining some comprehension of the level of the audience and understanding the culture.

If you want constructive feedback then post asking "what do you think of this idea". I have not seen anyone seriously lambasted for posting ideas in this way.

Nobody here is a VIP, especially not me. We are just a bunch of people trying to help each other work through what is undoubtedly one of the most convoluted applications available. People are welcome to contribute at every level. Even wrong answers help because others will learn from the misunderstanding and it often leads to an excellent to someone who really knows the details.
 

HAMMAMABUARQOUB

Registered User.
Local time
Today, 13:38
Joined
Jul 29, 2009
Messages
75
thanks for tips...
i will stop solving the non-problems
i will stop acting like an expert while i am not,,,
i will stop using the ooooh opps and others you mentioned and use the vomite smiles instead
i will seek that little bit of the respect others gained by trusted advice
i will not find any "dozens of codes" and paste them here..

yes I am an expert of MS Access, I made alot of contributions in other community, not because you don't know me means I did nothing trusted or i have no experience with the advanced management and coding of Access...all what you saw me posting is of my own work.. and my own codes, not just this "at best ordinary tip" but as I said i made alot of thinks and codes in VBA..
but posting such "ordinary tip" maybe very useful for some other people not neccessary to be jugded only by you...and in that way...see this sentence..
Even wrong answers help because others will learn from the misunderstanding and it often leads to an excellent to someone who really knows the details.
i tell you,,, this community will respect me and you will see.. am not saying this will happen today.. but be patient and sorry to "waste" you time...
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:38
Joined
Jan 20, 2009
Messages
12,849
What would be the reason for separating the hours, minutes and seconds and storing them as separate fields in a log file?

And why not write the time (or its derived components if you wish) directly to the log table? What is the benefit of putting them on the form first?

Why are you using label captions to display integers? They will be held as strings. The Val function is being used to convert the strings back to numbers for saving to the table. If textboxes were used, the data could be held as integers and this reconversion would not be required.

Text boxes can be made to look like labels by setting their background and border to transparent. Set them as locked and disabled to prevent the user interacting.

As text boxes, their Control Source could be set to the time functions. The timer event would then only require a requery of the controls. This would probably use less memory and be faster than the demonstrated technique. The VBA code would certainly be simpler.

During minute 5 the log will be written on every timer interval. The rest of the time the log would be written at the end of each minute. Why would you design this behaviour?

If you were going to log at the end of each minute then why not have the timer set at 60000ms and simply write the time and information to the log table? This would be far more efficient than running code every second.

I get the feeling you have tried to demonstrate two different purposes in the same code. Perhaps also just one of the logging intervals was meant to be used. But you haven't said this and it makes it confusing.

Unfortunately your post doesn't decribe the intent very well. Anyone who would be able to make sense of it would not need it demonstrated while those who might potentially find something like this helpful are likely to be confused and disappointed.

We do try to make sure code is reasonably reliable particularly if it is put forward as a tip. Unfortunately when it contains bewildering techniques or logical errors it takes far longer to analyse.

The internet is full of posts about Access. Many are obsolete, inefficeint or just plain wrong. If you are going to post tips they should be efficient, well tested and clearly commented. Your post looks like aircode, is not well explained and is not very sophisticated.

I'm sorry we got off to a bad start. Your energy and enthusiasm are most welcome as we always need more knowlegable people to answer questions.
 

HAMMAMABUARQOUB

Registered User.
Local time
Today, 13:38
Joined
Jul 29, 2009
Messages
75
Ok..
Can you change all that for me and contribute to the solution of this no-problem...do it it's ok as you see it very mysterious thing to handle the codes and controls in this way! Do what you see better and thanks alot...
I'm sorry we got off to a bad start. Your energy and enthusiasm are most welcome as we always need more knowlegable people to answer questions.
THAT WAS my fault in the first place coz I lead some of you to the "vomit" situation but ... a bad start sometimes can lead to a very happy and healthy communication...I will be more than hppy to exchange and contribute to this site...
 

Rich

Registered User.
Local time
Today, 10:38
Joined
Aug 26, 2008
Messages
2,898
Also be aware that using the Timer event on a form causes unexpected and unwanted side effects on forms, but then as an Access expert you would of course already know that
 

Users who are viewing this thread

Top Bottom