Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Christchurch
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    save record code (2000)

    Hi, I have a form that is used to enter some figures, then by clicking a button, preview the current record in a report, which works fine if the record has been saved previously. The problem is that the user may not realise the need to move to a new record to save it, then move back, or choose Save Record from the Record menu. Until they do one of these things, the data entered won't populate the report correctly. Can anyone help me with some code to add to the start of the OnClick event that opens the report, that will first save the current record.

    Thanks, Roger

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: save record code (2000)

    Woja
    Dependent on how your data is entered, you can use a simple line of code:

    <pre>RunCommand acCmdSaveRecord</pre>


    You can use this code either before you call the report, or on the After_Update of the last record entered, before the report button is pressed.
    If you want to view the records in real time, you can use either:

    <pre>Me.Requery</pre>


    or

    <pre>Me.Refresh</pre>


    or

    <pre>Me.ReCalc</pre>

    for numeric data.

    A glance at your preview code would be helpful if you are still requiring more info.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Christchurch
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: save record code (2000)

    Thanks Dave. RunCommand acCmdSaveRecord works fine.

    Regards
    Roger

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

    Re: save record code (2000)

    In addition to Dave's excellent advice, you can test if the record needs to be saved:

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    The Dirty property of a form is True if the current record has been modified since it was last saved (thus needs to be saved before opening the report), and False otherwise.

Posting Permissions

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