Results 1 to 8 of 8

Userform Verification

Threaded View

  1. #1
    Registered User
    Join Date
    12-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    98

    Userform Verification

    I would like to add a piece of code into the user form that will check and verify if a part has already been added so as to avoid multiples in a user-driven/created database.

    here is a repost of the current code i am using for the user form (I have posted it before in another thread .. Blane245 helped me out with a different question I had)

    Private Sub cmdAdd_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Part_Center")
    
    'the second worksheet
    Dim ws2 As Worksheet
    Set ws2 = Worksheets(Me.cmbSheet.Value)
    
    
    'find  first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
      
    'check for a Part Number
    If Trim(Me.txtModel.Value) = "" Then
      Me.txtModel.SetFocus
      MsgBox "Please enter a Model Number, Part Number or Name"
      Exit Sub
    End If
    
    'check for Promo Pricing
    If Trim(Me.txtPromo.Value) = "" Then
      Me.txtPromo.SetFocus
      MsgBox "Please enter the Promo Pricing"
      Exit Sub
    End If
    
    'check for Standard Pricing
    If Trim(Me.txtStandard.Value) = "" Then
      Me.txtStandard.SetFocus
      MsgBox "Please enter the Standard Pricing"
      Exit Sub
    End If
    
    'check for Install Required Time
    If Trim(Me.txtInstall.Value) = "" Then
      Me.txtInstall.SetFocus
      MsgBox "Please enter the required Install Time"
      Exit Sub
    End If
    
    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.txtModel.Value
    ws.Cells(iRow, 2).Value = Me.txtBrief.Value
    ws.Cells(iRow, 3).Value = Me.txtDesc.Value
    ws.Cells(iRow, 4).Value = Me.txtPromo.Value
    ws.Cells(iRow, 5).Value = Me.txtStandard.Value
    ws.Cells(iRow, 6).Value = Me.txtInstall.Value
    ws.Cells(iRow, 7).Value = Me.txtManuf.Value
    ws.Cells(iRow, 8).Value = Application.UserName
    ws.Cells(iRow, 9).Value = Date
    
    'do the same for the other worksheet
    'find  first empty row in database
    iRow = ws2.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    
    'copy the data to the database
    ws2.Cells(iRow, 1).Value = Me.txtModel.Value
    ws2.Cells(iRow, 2).Value = Me.txtDesc.Value
    ws2.Cells(iRow, 4).Value = Me.txtPromo.Value
    ws2.Cells(iRow, 3).Value = Me.txtStandard.Value
    ws2.Cells(iRow, 5).Value = Me.txtInstall.Value
    ws2.Cells(iRow, 6).Value = Me.txtManuf.Value
    
    
    'clear the data
    Me.txtModel.Value = ""
    Me.txtBrief.Value = ""
    Me.txtDesc.Value = ""
    Me.txtPromo.Value = ""
    Me.txtStandard.Value = ""
    Me.txtInstall.Value = ""
    Me.txtManuf.Value = ""
    Me.txtModel.SetFocus
    End Sub
    Last edited by jabryantiii; 02-17-2010 at 07: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