Userform Help in VBC

G

Guest

I have a userform set up and for the most part it works. It is a form that
participants from my seminars enter their information in at the end of the
meeting. I have noticed when I have been testing it that even though I have
text in all the boxes and I click the "submit button" which is a
commandbutton I sometimes get a popup box box that says I need to enter the
all information, even though all the information is entered. Here is the
code, do you see something that looks funny. Thanks

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("ParticipantData")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for particpant info
If Trim(Me.txtFirstName.Value) = "" Then
Me.txtFirstName.SetFocus
MsgBox "Please enter your information"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtFirstName.Value
ws.Cells(iRow, 2).Value = Me.txtLastName.Value
ws.Cells(iRow, 3).Value = Me.txtAddress.Value
ws.Cells(iRow, 4).Value = Me.txtCity.Value
ws.Cells(iRow, 5).Value = Me.txtState.Value
ws.Cells(iRow, 6).Value = Me.txtZip.Value
ws.Cells(iRow, 7).Value = Me.txtHomePh.Value
ws.Cells(iRow, 8).Value = Me.txtWorkPh.Value
ws.Cells(iRow, 9).Value = Me.cboAgeGrp.Value
ws.Cells(iRow, 10).Value = Me.cboStatus.Value
ws.Cells(iRow, 11).Value = Me.cboCombIncome.Value
ws.Cells(iRow, 12).Value = Me.cboOwnHome.Value
ws.Cells(iRow, 13).Value = Me.cboLoanType.Value
ws.Cells(iRow, 13).Value = Me.cboLoanYear.Value
ws.Cells(iRow, 14).Value = Me.txtEmail.Value

'clear the data
Me.txtFirstName.Value = ""
Me.txtLastName.Value = ""
Me.txtAddress.Value = ""
Me.txtCity.Value = ""
Me.txtState.Value = ""
Me.txtZip.Value = ""
Me.txtHomePh.Value = ""
Me.txtWorkPh.Value = ""
Me.cboAgeGrp.Value = ""
Me.cboStatus.Value = ""
Me.cboCombIncome.Value = ""
Me.cboOwnHome.Value = ""
Me.cboLoanType.Value = ""
Me.cboLoanYear.Value = ""
Me.txtEmail.Value = ""
Me.txtFirstName.SetFocus

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top