Hi I have this userform that finds,adds and updates data.
When it comes to my update sub I get the error in the title. The code also works out month,monthname,year, from a data entry.
Private Sub cmbAmend_Click()
On Error GoTo cmbAmend_Click_Error
If Not IsDate(Me.txtDate) Then
MsgBox "Input must be a date in the format: 'dd/mm/yyyy'", _
vbCritical, "Data Miss-Match"
GoTo Cleanup
Else
Me.txtDate = Format(Me.txtDate, "dd/mm/yyyy")
End If
Application.ScreenUpdating = False
If r <= 0 Then Exit Sub
Set c = ws.Cells(r, 1)
c.Value = CDate(Me.txtDate) 'write amendments to database
c.Offset(0, 1).Value = Me.txtEtch.Value
c.Offset(0, 2).Value = Me.txtGreyFlash.Value
c.Offset(0, 3).Value = Me.txtwhiteflash.Value
c.Offset(0, 4).Value = Me.txtConductive.Value
c.Offset(0, 5).Value = Me.AreaBox.Value
c.Offset(0, 6).Value = Application.WorksheetFunction.WeekNum(Me.txtDate.Value)
c.Offset(0, 9).Value = MonthName(Me.txtDate.Value)
c.Offset(0, 8).Value = Month(Me.txtDate.Value)
c.Offset(0, 7).Value = Year(Me.txtDate.Value)
'restore Form
Me.cmbAmend.Enabled = False
Me.cmbDelete.Enabled = False
Me.cmbAdd.Enabled = True
' ClearControls
Me.Height = frmHt
If Sheet4.AutoFilterMode Then Sheet4.Range("A2").AutoFilter
Cleanup:
On Error Resume Next
Application.ScreenUpdating = True
Terminate:
On Error GoTo 0
Exit Sub
cmbAmend_Click_Error:
MsgBox "There is an issue with cmbAmend_Click " & vbCrLf & vbCrLf & _
Err.Number & " (" & Err.Description & ")", vbCritical, _
"Something went wrong..."
Resume Cleanup
End Sub
Bookmarks