Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Chicago, IL
    Posts
    154

    Unanswered: Can anybody find a problem with this code?

    Hiya,

    Here's some code I generated that is supposed to present a user with a yes/no choice before overwriting a field.

    Specifically, I am looking for problems with the IF and MSGBOX portions. I dunno if i have too many if's in there or what but when i go to click the button, it doesn't do anything! nada...

    Thanks in advance for your consideration!

    ============================

    Private Sub UpdateAmendment_Click()
    On Error GoTo Err_UpdateAmendment_Click

    If Forms![Contract Maintenance Form]![Maintenance Form subform].Form![Amendment/Contract] <> "" Then
    If MsgBox("Scanned contract already exists! Are you sure you want to replace it?", vbYesNo) = vbYes Then

    Dim stDocName As String

    stDocName = "Update Amendment Query"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    MsgBox "Data entered successfully! Either enter another record or exit."
    Forms![Contract Maintenance Form]!ProductLookup.SetFocus
    Forms![Contract Maintenance Form]!ProductLookup.Text = ""
    Forms![Contract Maintenance Form]!Filename.SetFocus
    Forms![Contract Maintenance Form]!Filename.Text = ""
    Forms![Contract Maintenance Form]!ProviderNumber.SetFocus
    Forms![Contract Maintenance Form]!ProviderNumber.Text = ""
    Me.Form.Refresh

    Else

    MsgBox "Aborted. Please Start Over"
    Me.Form.Refresh
    Exit Sub
    End If
    End If

    Exit_UpdateAmendment_Click:
    Exit Sub

    Err_UpdateAmendment_Click:
    MsgBox Err.Description
    Resume Exit_UpdateAmendment_Click

    End Sub

    ============================

  2. #2
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    You need to move the End If's before the exit sub(s).

  3. #3
    Join Date
    Oct 2003
    Location
    Chicago, IL
    Posts
    154
    Ahhh. yes! now it doesn't work if the field ISN'T blank but I'll whack away at it! Thanks a lot for your help!

Posting Permissions

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