Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Posts
    41

    Unanswered: Timer in Textbox

    Good day,

    I am looking to manage 15 min break periods for a group of 35 people. What I have in mind is a list of people on a form and a textbox next to there name. When they begin there break I would click a option button or something and the 15 minute countdown would begin in the textbox. Once complete just reset it back to 15 minutes.
    Is there a way to go about this?

    Any advice would be great.

  2. #2
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    Quote Originally Posted by justlearning200
    Good day,

    I am looking to manage 15 min break periods for a group of 35 people. What I have in mind is a list of people on a form and a textbox next to there name. When they begin there break I would click a option button or something and the 15 minute countdown would begin in the textbox. Once complete just reset it back to 15 minutes.
    Is there a way to go about this?

    Any advice would be great.
    Off the top of my head I might do something like this:

    Place 35 unbound text boxes on a form and of course label then Jack, Bill and Harry etc.

    Place a macro for OnClick on each text box that set the value of the text at 15. Each macro would have the condition that it would only run when the text box had a 0 in it.

    Next I would make a macro to run on the OnTimer event and set out, lets day 1 minute.

    This macro would have 35 action lines and all for SetValue. The Setvalue actions would simply be

    Item [Textboxname]
    Expression [Textboxname]-1

    Each action line would have a condition that the SetValue only runs when the entry in the text box was >0

    If you santed to be more precise you could set the OnTimer to run every 30 seconds and then the SetValue action would be

    Item [Textboxname]
    Expression [Textboxname]-.5

    The above will surfely be crude to what some others will say but it should quickly get you over the line.

    A small tip. If do this name all text boxes with names like 1, 2, 3, 4 etc because when you make the Setvalues for the OnTimer event you simply do one action line and its condition and then copy and paste and then just run down the list and change the text box names in the macro.

    Mike

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Alternately you could store the time along with a user record from an onclick event or something, then with the ontimer event, do a (15 - datediff("m", timefield, now()))

    Just a thought
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Jul 2003
    Posts
    41
    Thank you for the replies.

    Just a couple of questions, because my access skills are a little weak.

    I understand this part:

    "Place a macro for OnClick on each text box that set the value of the text at 15."

    Mike not really sure what you meant by the following statements:

    "Each macro would have the condition that it would only run when the text box had a 0 in it."

    "This macro would have 35 action lines and all for SetValue. The Setvalue actions would simply be

    Item [Textboxname]
    Expression [Textboxname]-1"

    If you have a sec could you explain it to me a little further.

    Thank you

  5. #5
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    Firstly, I use Access 95 so what follows might be a bit different in much later versions.


    Thank you for the replies.

    Just a couple of questions, because my access skills are a little weak.

    Mike not really sure what you meant by the following statements:

    "Each macro would have the condition that it would only run when the text box had a 0 in it."

    "This macro would have 35 action lines and all for SetValue. The Setvalue actions would simply be

    Item [Textboxname]
    Expression [Textboxname]-1"

    If you have a sec could you explain it to me a little further.


    If you go to the part where you make a macro, in A95 there is Run, Dsesign and New. Design is for existing macros so you go to New. There are 3 columns

    Condition, Action and Comment. You may need to click on View on the Tool bar and then click Conditions so as to see that column. Don't worry about Comments column.

    Click on the first action line and that should give you a drop dowm list with all the macro actions available and one of them will be SetValue, so select that action.

    At the bottom of the macro screen you will see Item and Expression.

    Item is what you are going to change, that is, Set its Value. Expression is what you are goint to set it with, in other words the Value.

    Let us assume that you call your text boxes 1, 2, 3 etc and we will also assume that your form names Smoko

    The Item will be

    [Forms]![Smoko]![1] The [1] would be [Jack] if that is what the text box was called.

    The Expression will be

    [Forms]![Smoko]![1]-1

    Thus when the macro runs on the Timer and lets say evey 60 seconds then the starting value in your text box is 15 and the value is set to 15-1, thus 14.

    So in another minute it become 14-1

    In the conditions column you would have

    [Forms]![Smoko]![1]>0

    This means that after 15 minutes when the text box value is reduced to 0 then SetValue actioln for the appropriate text box will not run other wise you would start to get minus numbers.

    Onced you made one action line and its condition column then on the left hand side (looks like a record selector on a table) place the mouse the arrow and click and the whole line will turn black. Now Copy and then click on the next action line and then paste. Then turn both lines black and copy and then down to the third line and Paste and the two extra will go in. Then copy the 4 lines and so on.

    One the 35 action and condition lines are there then just run down and change the text box name in each.

    At the very end of the macro I would also put in a SaveRecord action. In Access 95 that is done from the DoMenuItem. I think in later versions of Access it is DoCmd.

    Provided the form in question is the active form then you do not need to used the full reference as in [Forms]![Smoker![1] you only need the [1], [2], [3] etc

    Thus you can do the SetValue as

    Item [1]
    Expression [1]-1

    For the macro that runs OnClick then that will be a SetValue

    Item [Forms]![Smoko]![1]
    Expression 15

    The condition column will have

    [Forms]![Smoko]![1]=0

    Thus if click and there is still 7 minutes to go the value will not be reset to 15.

    By the way, if you master the SetVaue action and also conditions you will be amazed at how much you can do in Access and especially if you do macro actions OpenForm and Open query. SetValue also lets you change colours, dimensions of text boxes on labels, make things visible, change the record source of the form plus many other things.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •