Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Updating data (XP)

    I have a form that I use to edit or update information in a table and then to display the data in a report. The form has a command button that launches the report. Let's say I change a date field and then click the "Display Calendar" command button--the new information I just entered into the form does not appear on the report. If I want that information to display in the report (calendar), I must first close the form and then launch the report. That's a bit inconvenient.

    I had a similar problem with an earlier project, and you good people here helped my fix it. (If I'm not mistaken, my hero was Hans.) I copied that code and tried to paste it into the code for the OnClick event procedure for my command button. The code:

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    However, the VBA editor found a problem, and I can't figure out where the problem lies. Here's the code for the command button, without the "Me.Dirty" stuff.

    <font face="Georgia">Private Sub cmdOpenCalendar_Click()
    On Error GoTo Err_cmdOpenCalendar_Click

    Dim stDocName As String

    stDocName = "rptEvents"
    DoCmd.OpenReport stDocName, acPreview

    Exit_cmdOpenCalendar_Click:
    Exit Sub

    Err_cmdOpenCalendar_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenCalendar_Click

    End Sub</font face=georgia>

    So...can someone--pretty please--show me how to work this Me.Dirty line into the code so it'll work. Thank you!!

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

    Re: Updating data (XP)

    Lucas,

    It shouldn't be a problem.

    Private Sub cmdOpenCalendar_Click()
    Dim stDocName As String

    On Error GoTo Err_cmdOpenCalendar_Click

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If

    stDocName = "rptEvents"
    DoCmd.OpenReport stDocName, acPreview

    Exit_cmdOpenCalendar_Click:
    Exit Sub

    Err_cmdOpenCalendar_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenCalendar_Click

    End Sub

    If you still have problems, temporarily comment out the line "On Error GoTo Err_cmdOpenCalendar_Click" by inserting an apostrophe ' before it. If an error occurs during execution of the On Click event procedure, note the error message, then select Debug and see which part of the code is highlighted.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Updating data (XP)

    Yessir! That did it! Thanks again, Hans! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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