I am having all sorts of problems with a userform that I created. The current problem that I am having is that I am getting a run-time error 438 message when I click the "Log" command button. This button is supposed to 1) validate the entries on the userform; 2) write the data from the userform to a spreadsheet log; and 3) save the log.
The error seems to be occurring in step 2 of the above. Attached is the workbook and below is the code for the command button.
Private Sub cmdLog_Click()
Dim rowcount As Long
Dim ctl As Control
'Populate Ending time
Me.txtEnd = Format(Now, "HH:MM:SS")
'Calculate elapsed time
Me.txtElapsed = Format((TimeValue(txtStart.Value) - TimeValue(txtEnd.Value)), "HH:MM:SS")
'Validate entries
If Me.cboPrintedBy.Value = "" Then
MsgBox "Please select the name of the person doing the fingerprinting from the drop-down list.", vbExclamation, "Log Entry"
Me.cboPrintedBy.SetFocus
Exit Sub
End If
If Me.txtName.Value = "" Then
MsgBox "Please record the name of the applicant being fingerprinted.", vbExclamation, "Log Entry"
Me.txtName.SetFocus
Exit Sub
End If
If Me.cboReason.Value = "" Then
MsgBox "Please select the reason for the fingerprints from the drop-down list.", vbExclamation, "Log Entry"
Me.cboReason.SetFocus
Exit Sub
End If
If Me.optApp.Value = "false" And Me.optCID.Value = "False" Then
MsgBox "Please indicate if the print cards will be processed by CID or taken by the applicant.", vbExclamation, "Log Entry"
Exit Sub
End If
'Record data to spreadsheet
rowcount = Worksheets("2011 Log").Range("a1").CurrentRegion.Rows.Count
With Worksheets("2011 Log")
.Offset(rowcount, 0).Value = Me.txtDate.Value
.Offset(rowcount, 1).Value = Me.txtStart.Value
.Offset(rowcount, 2).Value = Me.txtName.Value
.Offset(rowcount, 3).Value = Me.cboReason.Value
.Offset(rowcount, 4).Value = Me.cboPrintedBy.Value
.Offset(rowcount, 5).Value = Me.txtEnd.Value
If Me.optApp.Value = True Then
.Offset(rowcount, 6).Value = "Go"
ElseIf Me.optCID.Value = True Then
.Offset(rowcount, 6).Value = "Stay"
End If
.Offset(rowcount, 7).Value = Me.txtElapsed.Value
End With
'Save the log
ActiveWorkbook.Save
End Sub
Bookmarks