Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update field contents (2002)

    I know this is a silly thing that I've probably done a number of times before but I just can't think how......

    I have a form with 2 unbound fields in the form header which are used to select data from a table and the returned fields in the detail section (a continuous form). QuantityIssued, DeliveryStock and StockTake. If I enter values into these fields then move to either of the unbound fields to change data, the changes to the 3 fields aren't saved. If I move to a new record before going to either of the unbound fields then the changes are saved.
    I know it's something really dumb, but how do I force the update of this record when I move to the unbound selection boxes

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

    Re: Update field contents (2002)

    The default action for Access is to save a record automatically. We'd need to know more about your form and how the unbound text boxes work.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update field contents (2002)

    Hans
    Should it save even when I haven't left the record? or should moving to the unbound fields in the form be enough to update the record?
    John

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

    Re: Update field contents (2002)

    No, just clicking in one of the unbound text boxes won't save the record. Access saves the record when you move to another record or close the form.
    Why should the record be saved when you click in one of those text boxes?

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

    Re: Update field contents (2002)

    You could put code in the On Enter event of the text boxes. Say you have a text box txtThis:
    <code>
    Private Sub txtThis_Enter()
    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If
    End Sub
    </code>
    You must do this for both text boxes in the form header.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update field contents (2002)

    I would like the record to be updated when I move to either of the unbound fields.
    When I update the unbound fields, they run queries to append new records to the table (these include a date and also look up the values of the previous day and if neccessary amend todays values. The problem is that if I didn't move to another record before changing the date in the unbound field then the values I look up haven't been modified, hence I need a method of forcing an update when I move from the detail section to the unbound fields.

  7. #7
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update field contents (2002)

    Excellent - many thanks. I did think it was something about the OnDirty function, but didn't know what to use to do the record update.
    Looking at the options available for RunCommand they seem to be the choices available via the Access menus - is this correct?
    John

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

    Re: Update field contents (2002)

    Yes, RunCommand provides the VBA equivalent of many of the menu options available in Access. For example, if you wanted to display the Find dialog, you'd use Edit | Find, and the VBA equivalent is

    RunCommand acCmdFind

Posting Permissions

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