Results 1 to 2 of 2

Thread: Check Duplication data entries in DBGrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Posts
    3

    Post

    i am using unbound dbgrid to allow user to add, edit or delete any data about the purchase order details.

    the problem is the item ID entered should not be duplicated since it is a unique key in the database.

    i got problem when trying to write the code to check the row entries in the Item ID column each time the user enter that data.

    can someone help ?

    thanks

  2. #2
    New Member
    Join Date
    Apr 1999
    Posts
    4

    Post

    In the Before Column Update Event run a SQL statement to applies only to the column in question. Check to see if entered value alrady exists in the table and clear the entered value and send a message box to notify the user.

    ie:
    Private Sub grdYourGridName_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)

    'The Column # for ID is 1

    Select Case ColIndex

    Case = 1

    Set Recordset = "Select ID from TableName
    Where ID = grdYourGridName.col(1).Text

    If Not Recordset.BOF and Not Recordset.EOF Then

    Cancel = True
    msgbox "Duplicate ID Number Entered"

    End If

    Hope this helps

    David Ridgway
    [email protected]

Posting Permissions

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



Click Here to Expand Forum to Full Width