Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    11

    Unanswered: VB help in access

    I have 2 command buttons I'm trying to combine, a Save Record button and an email report button. I'm trying to combine the email report command to the save record command, this is what i have:

    If.....

    Else
    On Error GoTo Err_Save_Record_Click
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Exit_Save_Record_Click:
    Exit Sub

    Err_Save_Record_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_Click

    Refresh
    DoCmd.OpenReport "Report#1", acViewPreview
    DoCmd.SendObject acSendReport, "Report#1", "Snapshot Format", "someone@someone.com", , , "Off the Phone Request", "Attached report is for someone."

    DoCmd.Close acReport, "Report#1", acSaveNo
    DoCmd.Maximize
    Forms("FRM OTP Requests").SetFocus

    End If

    The record will save, but the report will not display the current record. How would you go about combining these 2?

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    oh dear!

    you are telling the code to exit right up at the top - so it does!

    move
    Exit_Save_Record_Click:
    Exit Sub

    Err_Save_Record_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_Click

    down to just above the End Sub

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Feb 2004
    Posts
    11
    Thanks,

    it worked when I moved that section at the end, but I had to move it before the End If.

    Thanks again.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    no sir.

    that block needs to be at the end, the very last stuff before the End Sub.

    it will work if nothing much happens in your code after the endif, but it's sloppy and will explode sometime later when you add some more code after the endif

    anything after that Exit Sub line is not going to execute unless an error sends you to the error trap.

    izy
    currently using SS 2008R2

Posting Permissions

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