+ Reply to Thread
Results 1 to 3 of 3

Prevent duplicate entry in userform

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    61

    Prevent duplicate entry in userform

    i want to
    (1) Prevent duplicate number in ACCESSION NUMBER FIELD

    (2) If someone not writes ACCESSION NUMBER FIELD prevent from submiting....

    I SEARCHED A LOG BUT NOT WORKING I FOUND ONLY DUPLICATE ENTRY DELETE CODE..

    thanks in advance
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Prevent duplicate entry in userform

    try
    Private Sub cmdAdd_Click()
        Dim RowCount As Long
        Dim xlRng As Range
        
        If Trim(Me.Ac.Value) = vbNullString Then
            MsgBox "Please enter Ac.", vbOKOnly + vbInformation, "Error"
            Me.Ac.SetFocus
            Exit Sub
        End If
        
        Set xlRng = Worksheets("Sheet1").Columns(1).Find(What:=Me.Ac.Value, LookIn:=xlValues, lookat:=xlWhole)
        If Not xlRng Is Nothing Then
            MsgBox "Duplicate Ac.", vbOKOnly + vbInformation, "Error"
            Me.Ac.SetFocus
            Me.Ac.SelStart = 0
            Me.Ac.SelLength = Len(Me.Ac.Value)
            Exit Sub
        End If
        
        RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
        
        With Worksheets("Sheet1").Range("A1")
            .Offset(RowCount, 0).Value = Me.Ac.Value
            .Offset(RowCount, 1).Value = Me.Cl.Value
            .Offset(RowCount, 2).Value = Me.Ti.Value
            .Offset(RowCount, 3).Value = Me.S1.Value
            .Offset(RowCount, 4).Value = Me.S2.Value
            .Offset(RowCount, 5).Value = Me.Bo.Value
            .Offset(RowCount, 6).Value = Me.Ro.Value
            .Offset(RowCount, 7).Value = Me.La.Value
            .Offset(RowCount, 8).Value = Me.Pu.Value
            .Offset(RowCount, 9).Value = Me.Ye.Value
            .Offset(RowCount, 10).Value = Me.Ed.Value
            .Offset(RowCount, 11).Value = Me.Isbn.Value
            .Offset(RowCount, 12).Value = Me.PR.Value
            .Offset(RowCount, 13).Value = Me.pg.Value
            .Offset(RowCount, 15).Value = Me.Lo.Value
        
        End With
        RefreshSOUL
    End Sub
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    05-13-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Prevent duplicate entry in userform

    wowwwwwwwwwwwwwwwwww

    GENIUS MEN ))))))))))))))))) tehneXus BRO u r genius u coded so fast i have replaced accession number with textbox7 so i made changes and it worked very nice both queries solved ... i am a data entry operator u helped me lot may god bless u

+ 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