Hi guys,
I'm quite new to Access and coding in general and have been asked to create a database at work. I've been using the vast resources of the internet to help and have learned a lot in the month or so since I started. However, I have encountered a problem that I can't seem to find a solution for anywhere. I have a form for requesting an EQN (Engineering change essentially). Within the form I have a button that when clicked, saves the form and sends an email to the relevant person to grant the request. It also looks at the textboxes, which are bound to the fields in my table, to check that there is text in them and a warning message pops up if not. The code on this button works fine, but I also have a button on this form which opens a separate resubmission form for if an EQN request is rejected. I have literally copy and pasted the code from one button to the other, changed the names of the form etc and when I click the button on the resubmission form, nothing happens at all. It's as if there's no code behind the button whatsoever. I also have a form for the granting of these requests with the same button, I copy and pasted the code to that one and it worked fine. I'm just stumped as to why it's only on one particular form it doesn't work. I'll post the code below, and any help would be greatly appreciated.
TL;DR two buttons on separate forms with the exact same code, one works, the other doesn't.
Code:
I'm quite new to Access and coding in general and have been asked to create a database at work. I've been using the vast resources of the internet to help and have learned a lot in the month or so since I started. However, I have encountered a problem that I can't seem to find a solution for anywhere. I have a form for requesting an EQN (Engineering change essentially). Within the form I have a button that when clicked, saves the form and sends an email to the relevant person to grant the request. It also looks at the textboxes, which are bound to the fields in my table, to check that there is text in them and a warning message pops up if not. The code on this button works fine, but I also have a button on this form which opens a separate resubmission form for if an EQN request is rejected. I have literally copy and pasted the code from one button to the other, changed the names of the form etc and when I click the button on the resubmission form, nothing happens at all. It's as if there's no code behind the button whatsoever. I also have a form for the granting of these requests with the same button, I copy and pasted the code to that one and it worked fine. I'm just stumped as to why it's only on one particular form it doesn't work. I'll post the code below, and any help would be greatly appreciated.
TL;DR two buttons on separate forms with the exact same code, one works, the other doesn't.
Code:
Private Sub cmdSaveEmail_Click()
If IsNull(Me.Value_Stream.Value) Then
MsgBox "Please select a Value Stream", vbOKOnly, "Warning"
Me.Value_Stream.Undo
If IsNull(Me.Part_Number.Value) Then
MsgBox "You must enter a value into the part number field", vbOKOnly, "Warning"
Me.Part_Number.Undo
If IsNull(Me.Detailed_Description.Value) Then
MsgBox "You must enter the description", vbOKOnly, "Warning"
Me.Detailed_Description.Undo
If IsNull(Me.Raised_By.Value) Then
MsgBox "You must enter who is raising this request.", vbOKOnly, "Warning"
Me.Raised_By.Undo
Else
SaveRecord
Dim f As Form
Set f = Forms![frmEQNResubmit]
f.Filter = "ID=" & f!ID
f.FilterOn = True
DoCmd.SendObject acSendForm, f.Name, acFormatPDF, "EMAIL", , , "EQN Resubmit", "See Attached", True, ""
f.FilterOn = False
Set f = Nothing
End If
End If
End If
End If
End Sub