#1   Report Post  
Marcia3641
 
Posts: n/a
Default 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   Report Post  
Marcia3641
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm Data to Spreadsheet Andy Tallent Excel Discussion (Misc queries) 2 June 22nd 05 04:51 PM
Use the X button on a userform Greg B Excel Discussion (Misc queries) 3 May 16th 05 09:19 AM
Data Validation Cell - Move to UserForm thom hoyle Excel Worksheet Functions 0 April 28th 05 12:23 AM
Cell Content from UserForm Not Retained D.Parker Excel Discussion (Misc queries) 3 April 27th 05 04:56 PM
How can I run a macro in the background whilst a UserForm is visib cdb Excel Discussion (Misc queries) 3 February 10th 05 06:58 PM


All times are GMT +1. The time now is 10:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"