You can hide the aplication on initialising the userform. You have to be extremely careful that your code also restores the aplication o else you will find that he user has a hidden instance of excel running. I've tidied up your code & added the code to hide/unhide Excel
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("MainDataSheet")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
With ws
.Cells(iRow, 1).Value = Me.txtentrydate.Value
.Cells(iRow, 2).Value = Me.txtTargetLastName.Value
.Cells(iRow, 3).Value = Me.txtTargetFirstName.Value
.Cells(iRow, 4).Value = Me.txtTargetNickname.Value
.Cells(iRow, 5).Value = Me.CheckBox1.Value
If Me.CheckBox1.Value = True Then
.Cells(iRow, 5) = "Unk"
Else: .Cells(iRow, 5) = ""
End If
.Cells(iRow, 6).Value = Me.txtAddressNumber.Value
.Cells(iRow, 7).Value = Me.txtStreetName.Value
.Cells(iRow, 8).Value = Me.txtcaseagent.Value
.Cells(iRow, 9).Value = Me.txtSecondAgent.Value
.Cells(iRow, 10).Value = Me.CheckBox2.Value
If Me.CheckBox1.Value = True Then
.Cells(iRow, 10) = "Yes"
Else: .Cells(iRow, 10) = ""
End If
.Cells(iRow, 11).Value = Me.txtTypeWarrant.Value
.Cells(iRow, 13).Value = Me.txtSupervisor.Value
.Cells(iRow, 14).Value = Me.txtComments.Value
.Cells(iRow, 15).Value = Me.CheckBox3.Value
.Cells(iRow, 16).Value = Me.txtdateclosed.Value
End With
'clear the data
With Me
.txtentrydate.Value = ""
.txtTargetLastName.Value = ""
.txtTargetFirstName.Value = ""
.txtTargetNickname.Value = ""
.txtAddressNumber.Value = ""
.txtStreetNa.Value = ""
.txtcaseagent.Value = ""
.txtSecondAgent.Value = ""
.txtTypeWarrant.Value = ""
.txtSupervisor.Value = ""
.txtComments.Value = ""
.txtdateclosed.Value = ""
.CheckBox2.Value = ""
.CheckBox1.Value = ""
.CheckBox3.Value = ""
.txtentrydate.SetFocus
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
'hide Excel application
Application.Visible = False
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'uhide Excell application
Application.Visible = True
End Sub
Bookmarks