+ Reply to Thread
Results 1 to 2 of 2

Userform Help in VBC

  1. #1
    Marcia3641
    Guest

    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. #2
    Marcia3641
    Guest

    RE: Userform Help in VBC

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1