Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

checking duplicate entry

hi,
I am developing a database program.i am using adodb.Suppose user entered records in table with one primary keyfield.Next time when user add new record by Clicking add button recordset.addnew procedure will be executed which appends blank record .user will enter keyfield in textbox and press enter.when he press enter in code some procedure should execute which find whether this keyfield is already there or not.If by mistake user is making duplicate entry, message should pop up as "Record already exists" and cancel addnew procedure and show contents of that record.if it's not duplicate entry then it should follow normal procedure.
I have little idea how to do it but please guide me in details .please help me urgently.
Ganesh :)

Comments

  • zaib_awanzaib_awan Member Posts: 9
    : hi,
    : I am developing a database program.i am using adodb.Suppose user entered records in table with one primary keyfield.Next time when user add new record by Clicking add button recordset.addnew procedure will be executed which appends blank record .user will enter keyfield in textbox and press enter.when he press enter in code some procedure should execute which find whether this keyfield is already there or not.If by mistake user is making duplicate entry, message should pop up as "Record already exists" and cancel addnew procedure and show contents of that record.if it's not duplicate entry then it should follow normal procedure.
    : I have little idea how to do it but please guide me in details .please help me urgently.
    : Ganesh :)
    :


    Use THis

    'Copy This Function and Paste into ur form or Moudle
    Public Function ChkUsed(CodeFieldName As String, CodeFieldValue As String, TableName As String) As Boolean

    'Check used value if is using any where
    Dim rstused As New ADODB.Recordset
    With rstused
    .Open "Select * from " & TableName & " where " & CodeFieldName & "='" & CodeFieldValue & "'", Cn, adOpenKeyset, adLockOptimistic
    If Not rstused.EOF Then
    ChkUsed = True
    Else
    ChkUsed = False
    End If
    End With
    End Function


    'HOW to Use This Function.
    if chkUsed("Code",2,TableName)=True then
    msgbox " Value Allready Exisits"
    endif
Sign In or Register to comment.