Yodelayheewho
Member
The code below was working perfectly until yesterday.
The code prevents the user from 'forgetting' to save before exiting the userform.
Here's an example of what's happening
1. Enter a date in txtReqPM but do not click the Save command button
2. Click on Exit command button
2. Select 'yes' to save changes
3. Runtime error 13. Type mismatch pops up
4. Debugs on the very next textbox, which is txtPMAssign
5. I end the debug and it unloads the userform
6. I reopen the userform, search for the same order to see if date in txtReqPM is saved and it is.
7. So, the Exit code is working as far as saving if I select 'yes', but I'm getting this error.
Because the debug was highlighted the next textbox, I double checked that my columns were aligned correctly and they are: txtReqPM is in Column 66 and txtPMAssign is in Column 67 and so forth.
Thank you in advance for your help.
The code prevents the user from 'forgetting' to save before exiting the userform.
Here's an example of what's happening
1. Enter a date in txtReqPM but do not click the Save command button
2. Click on Exit command button
2. Select 'yes' to save changes
3. Runtime error 13. Type mismatch pops up
4. Debugs on the very next textbox, which is txtPMAssign
5. I end the debug and it unloads the userform
6. I reopen the userform, search for the same order to see if date in txtReqPM is saved and it is.
7. So, the Exit code is working as far as saving if I select 'yes', but I'm getting this error.
Because the debug was highlighted the next textbox, I double checked that my columns were aligned correctly and they are: txtReqPM is in Column 66 and txtPMAssign is in Column 67 and so forth.
Code:
'Exit Button'
Private Sub cmbExit_Click()
If MsgBox("Save changes?", vbYesNo, "Exit form") = vbYes Then
Dim Shop_Order_Number As String
Dim n As String
Dim txt As String
n = txtNotes 'Overrides the default limit of characters in a textbox; allows unlimited characters***
Shop_Order_Number = Trim(txtShopOrdNum)
lastrow = Worksheets("Master").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Master").Cells(i, 4).Value = Shop_Order_Number Then
'redacted Columns 1-60'
Worksheets("Master").Cells(i, 61).Value = txtSrvTtl
Worksheets("Master").Cells(i, 62).Value = cboSrvGrp
Worksheets("Master").Cells(i, 63).Value = CDate(Me.txtConPO.Value)
Worksheets("Master").Cells(i, 64).Value = CDate(Me.txtE10.Value)
Worksheets("Master").Cells(i, 65).Value = CDate(Me.txtFinance.Value)
Worksheets("Master").Cells(i, 66).Value = CDate(Me.txtReqPM.Value)
Worksheets("Master").Cells(i, 67).Value = CDate(Me.txtPMAssign.Value)
Worksheets("Master").Cells(i, 68).Value = CDate(Me.txtSOATeam.Value)
Worksheets("Master").Cells(i, 69).Value = CDate(Me.txtApproved.Value)
Worksheets("Master").Cells(i, 70).Value = CDate(Me.txtSOACust.Value)
Worksheets("Master").Cells(i, 71).Value = CDate(Me.txtSOAE10.Value)
Worksheets("Master").Cells(i, 72).Value = CDate(Me.txtAR.Value)
Worksheets("Master").Cells(i, 73).Value = CDate(Me.txtCurPromDate.Value)
Worksheets("Master").Cells(i, 74).Value = CDate(Me.cboRecRev.Value)
Worksheets("Master").Cells(i, 75).Value = txtShipNotes
Worksheets("Master").Cells(i, 76).Value = CDate(Me.txtShipped.Value)
Worksheets("Master").Cells(i, 77).Value = txtName
Worksheets("Master").Cells(i, 78).Value = txtDiamond
Worksheets("Master").Cells(i, 79).Value = txtCustID
'redated Columns 80 -102'
End If
Next
ActiveWorkbook.Save
MsgBox "Your work is saved", vbOKOnly, "Exit form"
Else
End If
Unload MasterForm
End Sub
Thank you in advance for your help.