Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Userform Help in VBC
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 -- Marcia3641 |
#2
|
|||
|
|||
I figured it out!
-- Marcia3641 "Marcia3641" wrote: 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 -- Marcia3641 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UserForm Data to Spreadsheet | Excel Discussion (Misc queries) | |||
Use the X button on a userform | Excel Discussion (Misc queries) | |||
Data Validation Cell - Move to UserForm | Excel Worksheet Functions | |||
Cell Content from UserForm Not Retained | Excel Discussion (Misc queries) | |||
How can I run a macro in the background whilst a UserForm is visib | Excel Discussion (Misc queries) |