Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    May 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatic Date on Update (Access 2000 SR-1)

    I'm either missing something obviouse or my libraries arn't working.
    I'm trying to update a field in a subform after entering in a different column, basically I'm trying to apply an automatic updated date on a change of data in a related field for record keeping perposes.
    Does Date() normally work in Access form properties it does if used in a Query.?
    I've tried =Date() in the date field I'm intending as the recipient, should it take an address something like Forms![field]?

    If this is unclear ask for clarification. I'd be grateful for any assisstance?

    graliv

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

    Re: Automatic Date on Update (Access 2000 SR-1)

    If I understand correctly, you want to enter the current date in FieldA when the value of FieldB has changed. You need a little bit of code for this in the AfterUpdate event of the text box bound to FieldB:

    Private Sub txtFieldB_AfterUpdate()
    txtFieldA = Date
    End Sub

    In this code, txtFieldA and txtFieldB are the names of text boxes bound to FieldA and FieldB, respectively.

    If this is not what you wanted, or if you don't know how or where to enter this code, feel free to post back.

  3. #3
    New Lounger
    Join Date
    May 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic Date on Update (Access 2000 SR-1)

    Thank HansV.
    That solves the first part of my problem.
    But, That code only seems to update fields which already have a Date in them, also the date seems almost to be random.
    I think its something to do with the format.
    The field I'm entering into has the format: DD/MM/YY (I'm english!)

    Can you help
    Regards

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

    Re: Automatic Date on Update (Access 2000 SR-1)

    The Date function should return today's date. You can format it any way you like by setting the Format property of the text box; the format shouldn't be specified in the code.

    If you have a control on your form named Date, the code will use that instead of executing the built-in function Date. If you have created a custom function named Date, that will overrule the built-in function. (This is why it is not a good idea to give a field or custom function the same name as a built-in function). You might try using FieldA = Date() instead of just FieldA = Date.

    The code I suggested should change FieldA after the user has changed the value of FieldB. No more, no less.

    If you still have problems, try to explain the situation and what you want to accomplish in more detail; I'm not sure I understand it.

  5. #5
    New Lounger
    Join Date
    May 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic Date on Update (Access 2000 SR-1)

    Thanks. Sussed it.
    As you suggested it is the fault of a field called date in the form.
    No problems at this point.
    Very gratefull.

    Graliv

Posting Permissions

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