Results 1 to 3 of 3

Data Dump from User form upon error creating a duplicate row.

Threaded View

  1. #1
    Registered User
    Join Date
    03-20-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    7

    Data Dump from User form upon error creating a duplicate row.

    So I have my code working ALMOST!! I would like for the code to restart and not dump the data that it has gatered thus far into the spreadsheet, or it can but it seems that the data starts over again on a new line and duplicates itself. Here is the code and I greatly appreciate the knowledge and experience in advance.

    Private Sub CommandButton1_Click()
    
    
              Dim LastRow As Object
              Set LastRow = Sheet1.Range("a65536").End(xlUp)
              LastRow.Offset(1, 0).Value = TextBox1.Text 'Patient Name
              LastRow.Offset(1, 1).Value = ComboBox1.Value 'Staff Member
              LastRow.Offset(1, 2).Value = TextBox3.Text 'Tx
              LastRow.Offset(1, 3).Value = TextBox4.Text 'Appt. Date
              LastRow.Offset(1, 9).Value = TextBox5.Text 'Production Amount
                        
              If CheckBox1.Value = True Then Answer = "Yes"
              If CheckBox2.Value = True Then Answer = "No"
              
                          
    
    Select Case Answer
    Case Is = "Yes"
    LastRow.Offset(1, 4).Value = "Yes"
    Case Is = "No"
    LastRow.Offset(1, 4).Value = "No"
    Case Is = ""
    Response = MsgBox("You must Fill Out All Fields!"): Exit Sub
    End Select
    
    
    
    If CheckBox3.Value = True Then Answer = "Yes"
    If CheckBox4.Value = True Then Answer = "No"
    
    Select Case Answer
    Case Is = "Yes"
    LastRow.Offset(1, 5).Value = "Yes"
    Case Is = "No"
    LastRow.Offset(1, 5).Value = "No"
    Case Is = ""
    Response = MsgBox("You must Fill Out All Fields!"): Exit Sub
    End Select
    
    
    If CheckBox5.Value = True Then Answer = "Yes"
    If CheckBox6.Value = True Then Answer = "No"
    
    Select Case Answer
    Case Is = "Yes"
    LastRow.Offset(1, 6).Value = "Yes"
    Case Is = "No"
    LastRow.Offset(1, 6).Value = "No"
    Case Is = ""
    Response = MsgBox("You must Fill Out All Fields!"): Exit Sub
    End Select
    
    
    If CheckBox7.Value = True Then Answer = "Yes"
    If CheckBox8.Value = True Then Answer = "No"
    
    Select Case Answer
    Case Is = "Yes"
    LastRow.Offset(1, 7).Value = "Yes"
    Case Is = "No"
    LastRow.Offset(1, 7).Value = "No"
    Case Is = ""
    Response = MsgBox("You must Fill Out All Fields!", vbOKOnly): Exit Sub
    End Select
    
    
    If CheckBox9.Value = True Then Answer = "Yes"
    If CheckBox10.Value = True Then Answer = "No"
    
    Select Case Answer
    Case Is = "Yes"
    LastRow.Offset(1, 8).Value = "Yes"
    Case Is = "No"
    LastRow.Offset(1, 8).Value = "No"
    Case Is = ""
    Response = MsgBox("You must Fill Out All Fields!"): Exit Sub
    End Select
    
              MsgBox "Data Saved"
    
              Response = MsgBox("Do you want to enter another patient record?", _
                  vbYesNo)
    
              If Response = vbYes Then
                  TextBox1.Text = ""
                  ComboBox1.Value = ""
                  TextBox3.Text = ""
                  TextBox4.Text = ""
                  TextBox5.Text = ""
                  CheckBox1.Value = ""
                  CheckBox2.Value = ""
                  CheckBox3.Value = ""
                  CheckBox4.Value = ""
                  CheckBox5.Value = ""
                  CheckBox6.Value = ""
                  CheckBox7.Value = ""
                  CheckBox8.Value = ""
                  CheckBox9.Value = ""
                  CheckBox10.Value = ""
    
                  TextBox1.SetFocus
    
              Else
                  Unload Me
              End If
              
              
          End Sub
    Last edited by Leith Ross; 03-25-2013 at 09:35 PM.

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