Form code does not run - Deug? - URGENT

Christine Pearc

Christine
Local time
Today, 10:13
Joined
May 13, 2004
Messages
111
Form1 calls Form2. Form2 has a command button, but it doesn't work. I've never had to do this before, but I need to see Form2's command button code whilst the form is running. I've tried setting the breakpoint in the VB window, but it doesn't "catch" after I've closed the form. I've searched Help for debug topics but haven't found what I think I need.

Any help in a hurry would be really appreciated.
 
check the propertys of the command button. The button might have become 'disassociated' from the code. If this is the case, just switch the On Click property back to [Event Procedure]

If this isnt the problem, please post some extra details :)
 
Thanks for that. I've checked the button and it is associated with the code. When I click the button, there are no error messages and the programme doesn't become "hung", as I can click the Exit CmdBtn and exit back to the other screen.
 
Post the code up here then(the stuff that isnt working) and explain what you want it to do :)
 
Thanks for this, Workmad. By asking me to post the code, do I assume that there is no way for me to see the code working?

Anyway, here is the code. Quite simply, the code checks to ensure all form fields have been filled in (via a module). If all is well, e-mail addresses are obtained and e-mails are sent. That's it! If I could step through, it would be possible to see where it's getting its knickers in a twist, but all it does is...nothing!

Code:
Option Compare Database
Option Explicit
Dim OkToSend As Boolean

Private Sub cboNewProcessID_AfterUpdate()
    Me.NewProcessOwner.Value = cboNewProcessID.Column(2)
End Sub

Private Sub cmdSend_Click()

    On Error GoTo Err_cmdSend_Click

    OkToSend = CheckForNulls(Me)
    If OkToSend = False Then
        If IsNull(Me.ReviewNotes) Then
            Me!ReviewNotes = Format(Date, "Medium Date") & ":  Process reassigned from " & Me.cboProcessIDCurrent.Column(1) & " by " & cboProcessIDCurrent.Column(2) & " -- " & Me.ReassignNotes
        Else
            Me!ReviewNotes = Me.ReviewNotes & Chr(10) & Chr(10) & Format(Date, "Medium Date") & ":  Process reassigned from " & cboProcessIDCurrent.Column(1) & " by " & cboProcessIDCurrent.Column(2) & " -- " & Me.ReassignNotes
        End If
        
        Me!StatusID = 1
        Me.ProcessID = Me.cboNewProcessID
        
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        DoCmd.RunCommand acCmdSaveRecord

        MsgBox "The CAR system is going to automatically send an email. Microsoft security features may generate a message that says..." & Chr(13) & Chr(13) & _
       "    'A program is trying to automatically send email on your behalf. Do you want to allow this?'" & Chr(13) & Chr(13) & _
       "If you receive this message, please click YES to allow the program to proceed.", vbInformation, "Processing..."

        Dim OriginatorAddress As String
        OriginatorAddress = DLookup("[Email]", "qryEmployees", "[EmployeeID]=" & Forms![Review frm]!OriginatorID)
        Dim OriginatorName As String
        OriginatorName = DLookup("[FullName]", "qryEmployees", "[EmployeeID]=" & Forms![Review frm]!OriginatorID)

        Dim ProcessOwnerAddress As String
        ProcessOwnerAddress = cboNewProcessID.Column(3)
        SubjectLine = "New Corrective Action Request (CAR) " & [CARNum] & " for your review"
        MailList = ProcessOwnerAddress

        MyBodyText = "CAR " & [CARNum] & " has been opened against one of your processes. Please open the LMUK STS Corrective & Preventive Action System program from your desktop to review the CAR at your earliest convenience." & _
        Chr(13) & Chr(13) & "DATE OPENED:    " & Format([DateOpened], "Long Date") & _
        Chr(13) & Chr(13) & "ORIGINATOR/EMAIL:    " & Me.cboOriginatorID.Column(2) & _
        Chr(13) & Chr(13) & "CAR TITLE:    " & Me.Title & _
        Chr(13) & Chr(13) & "PROCESS:    " & Me.cboProcessID.Column(1) & _
        Chr(13) & Chr(13) & "PROBLEM:    " & Me.Description & _
        Chr(13) & Chr(13) & "SOLUTION:    " & Me.Solution

        DoCmd.RunMacro "SendMail"
        
        DoCmd.Close acForm, Me.Name
        DoCmd.Close acForm, "Review frm"
    End If

Exit_cmdSend_Click:
    Exit Sub

Err_cmdSend_Click:
    MsgBox "There was a problem emailing this CAR. Status has been reset to Requested." & Chr(13) & Chr(13) & _
           "Please try again. If you continue to have problems, use the Feedback option" & Chr(13) & Chr(13) & _
           "on the Main Menu to notify the Quality Administrator.", vbCritical, "Error"
    Resume Exit_cmdSend_Click

End Sub
 
If you set a breakpoint at the start(say, by the OkToSend = CheckForNulls(Me) line) , does it halt there? if so, just press f8 from that point and you can see where the code is going etc. If its not getting to the breakpoint , something is going very wrong somewhere.

I asked you to post the code as I was hoping it would be a simplish error (the kind where you just cant see whta going wrong, but someone else spots it in an instant). A quick glance shows a very simple error there though. If OkToSend is true, where is the else clause for it to go to? :)
 

Users who are viewing this thread

Back
Top Bottom