Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Feb 2004
    Location
    Jacksonville, Florida
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    expression builder (9.0/2000)

    I'm trying to build an expression code that activates: if the "start/evaluate task" box is checked then it automatically puts in the current (not changing) date in the "actual start" txt box of a form. However I want that date to stay even after other boxes are checked. This is the code I got from a friend to do this (but it returned nothing):

    Option Compare Database

    Private Sub Actual_Start_AfterUpdate()
    'If statement to auto fill/clear ActualStart when
    'box is checked.

    If Start / EvaluateTask = True Then
    ActualStart = Date

    ElseIf Start / EvaluateTask = False Then
    ActualStart = Null
    End If
    End Sub

    Attached is a picture of the form, so you have an idea of what boxes I'm talking about. And eventually I'll have to do the same thing for when the task is complete, while making sure the dates remain. Can anyone give me some help on this?
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression builder (9.0/2000)

    You have put the code in the After Update event of the "Actual Start" text box, but it should be in the After Update event of the "Start / Evaluate Task" check box.

    Private Sub Private Sub Start___Evaluate_Task_AfterUpdate()
    'If statement to auto fill/clear ActualStart when box is checked.
    If Me.[Start / EvaluateTask] = True Then
    Me.[Actual Start] = Date
    Else
    Me.[Actual Start] = Null
    End If
    End Sub

    Notes:

    1 The "ElseIf ... = False Then" is not necessary: if [Start / Evaluate Task] is not True, it is False automatically (unless you have a tristate check box, but I don't think that's useful here.

    2. Using spaces in the names of controls etc. can lead to trouble. If possible, avoid spaces and special characters such as / and # in the names of database objects, fields and controls. If you do want to use them, you MUST enclose them in square brackets in your code.

  3. #3
    Star Lounger
    Join Date
    Feb 2004
    Location
    Jacksonville, Florida
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression builder (9.0/2000)

    I put that code in, and nothing happened- am I doing something wrong? I went to the design view of the form and highlighted the txt box, then I right clicked and choose "expression builder." I copied and pasted that code and saved it. Then I went back to the box, right clicked and choose properties, then went to event and choose "event procedure" The three .... came up, and I clicked on it, the macro window appeared w/ the expression I wanted to I closed out. That's it right? Or do I have to do something else to link it to the box? And w/ this expression, employees w/ click the start button, we want the date to be filled into the "actual date" box- however, when they click another level of progress, we want the actual date to remain the same as if the start was still clicked. ... does this code perform that?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression builder (9.0/2000)

    Sorry, I don't understand, could you try again (and without things like w/ - English is not my native language)

  5. #5
    Star Lounger
    Join Date
    Feb 2004
    Location
    Jacksonville, Florida
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression builder (9.0/2000)

    well, when I put the code in the expression builder, nothing happened- so, other than putting the code in the expression builder, is there anything else I have to do to make that "start/..." box respond to that expression? Because when I put a check mark in the box, the date was not entered into the "actual start" box.

    The second part of the message was: the code you gave me to use, does that maintain the date, even if the employees check on another box. If you look at the picture attached in my original post- there is a yellow box with options of different levels of progress on a particular product (example: start, complete, and the 2 boxes in between). We want the form to return a date when that start box is checked. However, when the employee goes back in and clicks on a new level of progress, even though that check mark will move to the new box, we want the "actual date" to remain the same date as shows up with the start box checked. After I figure out the actual start date, I will build a similar code for when the Complete task box is checked. - Does that make a little more sense, I am sorry I know what I need to do, but I guess without being here for me to explain it in person, it is a little more difficult

    Oh, and w/ = with, and w/o = without It's just short hand stuff [img]/forums/images/smilies/smile.gif[/img]

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: expression builder (9.0/2000)

    Open the form in design view.
    Select the check box.
    Activate the Event tab of the Properties window.
    Click in the After Update event.
    Select Event Procedure from the dropdown list.
    Click the ... button to the right of the dropdown arrow.
    Paste the code from my reply without the first and last line into the empty line between Private Sub ... and End Sub.
    Check carefully that the names used are as those on your form.

    The code only runs if the user clicks on the check box. If the check box is turned of automatically by something else, the After Update event does not fire.

    (I knew that w/ is with, but I was confused about "employees w/ click the start button")

  7. #7
    Star Lounger
    Join Date
    Feb 2004
    Location
    Jacksonville, Florida
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: expression builder (9.0/2000)

    Thanks, I think that answered my question that we probably won't be able to do what we wanted to a "T"-and sorry, sometimes (most of the time) my brain thinks faster than my little paws can type <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  8. #8
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: expression builder (9.0/2000)

    From my reading of this thread, it looks to me like you don't need the else part of the code.

    The Else bit clears the date when you remove the tick from the box, and once the date is put in you want it to stay.

    Private Sub Private Sub Start___Evaluate_Task_AfterUpdate()
    'If statement to auto fill/clear ActualStart when box is checked.
    If Me.[Start / EvaluateTask] = True Then
    Me.[Actual Start] = Date
    End If
    End Sub

    If all the check boxes are part of an option group, then you could handle all the check boxes in one event by putting the code in the after update event for the option group. In this case you would be checking the value of the option group rather than the individual check boxes.
    Regards
    John



Posting Permissions

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