Solved How to find out the ID of the record to which I am trying to add a duplicate (1 Viewer)

Uldis007

New member
Local time
Tomorrow, 01:53
Joined
Nov 17, 2021
Messages
22
Hello everyone!
I need your help!

I have an order form where I can select an already registered customer from the drop-down list, but if the customer is not on the list, I can open the customer registration form and add a new customer via the order form. Customer table columns are indexed to avoid duplicates. If an existing customer is entered, I get a 3022 error and using On Error Go To access display a message that such a client is already registered.
Is it possible to find out the ID of this existing customer in any way so that when closing the customer registration form, this existing customer will appear in the corresponding fields of the application form?
 

jdraw

Super Moderator
Staff member
Local time
Today, 18:53
Joined
Jan 23, 2006
Messages
14,317
See this youtube video for related info.

Microsoft Access Add or Edit an Item in a Combo Box using a List Items Edit Form​

 

Eugene-LS

Registered User.
Local time
Tomorrow, 01:53
Joined
Dec 7, 2018
Messages
351
I had that idea but don't understand how to use Dlookup with multiple search criteria? ,. The customer table has three columns, Customer ID (Primary Key), Customer First Name,
Code:
Dim sVal As String, vVal
    sVal = "[Customer ID] = " & Me![Customer ID] & " AND [Customer First Name] = '" & Me![Customer First Name] & "'"
    vVal = DLookup("[Customer ID]", "[Your Table Name]", sVal)
    If vVal > 0 Then 'Found ...
        '  ...
    Else
        '  ...
    End If
 

Uldis007

New member
Local time
Tomorrow, 01:53
Joined
Nov 17, 2021
Messages
22
Your solution works great!
Thank you very much for your help!
Have a nice day!
 

Users who are viewing this thread

Top Bottom