1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Access - Closed Date/Time Stamp

Discussion in 'Business Applications' started by Dreambringer, Jan 24, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. Dreambringer

    Dreambringer Thread Starter

    Joined:
    Jan 19, 2005
    Messages:
    1,351
    Ok, here is what I have.

    An Access Database that will allow for "Trouble Tickets" to be issued.

    The way I have it set up now is a Status. This tells if the Ticket is Open or Resolved.

    What I also have is a "Closed Date" Field, what I am trying to do is set it up so that if the Status is changed to Resolved, it will put the "=NOW()" in the Closed Date field.

    Any suggestions. Everything seems to work fine, with the exception of this.

    Thanx in advance.
     
  2. OBP

    OBP Temporarily Banned

    Joined:
    Mar 8, 2005
    Messages:
    19,889
    Do it exactly as you said it. In the Status field's "after Update" event procedure put the code
    if me![status] = "Resolved" then [Closed Date] = now()
    hopefully the Status field has a drop down selection where "Resolved" is not typed in otherwise you may need to have
    if me![status] = "Resolved" or me![status] = "resolved" then [Closed Date] = now()
     
  3. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    This extended condition would only be necessary if the compare mode was Binary. All other modes perform case-insensitive comparisons. I agree that the ticket status should derive from a limited-to-list combo box.

    chris.
     
  4. Dreambringer

    Dreambringer Thread Starter

    Joined:
    Jan 19, 2005
    Messages:
    1,351
    Thanx for the responses!

    I understand how it works, but can not seem to get it to work.

    When I put it in, I get
    Code:
    Trouble Ticket can not find the macro "if me!... =now()"  
    The macro (or its macro group doesn't exist, or the macro is new but hasn't been saved.
    Note that when you enter the macrogroupname.macroname syntax in the argument, you must specify the name the macro's macro group was last saved under.
    
    Do I need to create a macro for this?
     
  5. OBP

    OBP Temporarily Banned

    Joined:
    Mar 8, 2005
    Messages:
    19,889
    Can you send it to me or post it on here?
     
  6. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    I think the issue is that you put that directly into the On AfterUpdate event property, when it is a programmatic solution.

    • Navigate to the appropriate control and open the Properties window.
    • Under the Event tab, type [Event Procedure] in the textbox corresponding to the On AfterUpdate label, then click the ellipsis (...). This opens the VBA Editor window.
    • In the VBA Editor, use a code model similar to OBP's suggestion:

      Code:
      Private Sub [color=blue]cboSomeComboBox[/color]_AfterUpdate()
        With Me
          If .[color=blue]cboSomeComboBox[/color].Value = "Resolved" Then
            .[Closed Date].Value = Now()
          End If
        End With
      End Sub
      
    From AccessVBA.com:

    Anyway.

    HTH

    chris.
     
  7. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    [bump]

    Randomly, you might have been able to use an IIf function directly in the event property without going through VBA, but I'm not sure. I think the process burden is the same either way.

    Code:
    IIf([[color=blue]cboSomeComboBox[/color]] = "Resolved", [Closed Date] = Now(), )
    
    Note the final comma, which is required to fulfill the FalsePart argument of IIf. I don't know if it'd work, but you could try it.

    chris.
     
  8. Dreambringer

    Dreambringer Thread Starter

    Joined:
    Jan 19, 2005
    Messages:
    1,351
    Thanx chris, that did it.. ( [Event Proceduer])

    I am going to try the other way as well. So what is "me!"?

    Solved btw! :)
     
  9. OBP

    OBP Temporarily Banned

    Joined:
    Mar 8, 2005
    Messages:
    19,889
    Me! is the Active Form.
     
  10. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    Oh, Me.

    This isn't a simple discussion, actually.

    The easy answer, and actually the only answer a lot of Access developers know (myself included until very, very recently), is that Me represents the current form or report. Therefore, to refer to a control within the current form, you'd use Me.ControlName or Me.Controls(Index). However, Me is actually a self-referent for any class object. Its analog in many other languages is this. Because forms and reports are basically class objects that have added features for extensibility in Access, Me is their self-referent. However, you'd also use Me to refer to a user-defined class object. The common example of a class object is a car.

    Consider a car and a parking lot. A car is a type of object with certain properties--make, model, color, capacity, etc. The common collection of properties signify a class: all objects of type car are transportive implements, for example. All cars are powered by engines of some variety and have some sort of capacity for an occupant entity. In simple terms, you know a car when you see one. You also know that cars can be very different. We say that an individual object of type car represents an instance of class car. The parking lot is full of car objects, or instances of class car. If we got in a particular car, we could refer to it in a few different ways. The most universal way would be to reference its index in the collection:

    AllParkingLots.CurrentParkingLot.ParkingSpaces("CurrentParkingSpace")

    But if we were already in the car, we could also use a more implicit reference:

    ThisCar.SeatingSpace

    In AccessVBA, Me is the self-referent keyword. The above line would be written

    Me.SeatingSpace.RearSeat

    which is the same as

    AllParkingLots.CurrentParkingLot.ParkingSpaces("CurrentParkingSpace").SeatingSpace.RearSeat

    That's an extended, maybe confusing example if you're not familiar with structured programming. In more practical terms, the following lines compute identically:

    Me.txtSomeTextboxControl.Value
    Forms(CurrentFormName).Controls("txtSomeTextboxControl").Value

    HTH

    chris.
     
  11. Dreambringer

    Dreambringer Thread Starter

    Joined:
    Jan 19, 2005
    Messages:
    1,351
    Actually that’s great! :) Thanx for the explanation! :) Not being to familier with VBA that explains alot! :) Bookingmarking now! :)
     
  12. cristobal03

    cristobal03

    Joined:
    Aug 5, 2005
    Messages:
    3,086
    No problem (y)

    chris.
     
  13. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/436986

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice