Results 1 to 2 of 2

Thread: Dlookup

  1. #1
    VBAX Newbie
    Apr 2020

    Question Dlookup

    in a ms db there are fields customer Name, address,Mobileno i want when user enter the mobile no other information should fill up automatically.for this first need a code to check the customer already exist or not.if not then a msg box appear that the customer is new please enter informstion manualy.
    To do this what code should be Used???.

  2. #2
    you use Form for you table so you can add Validation to MobileNo textbox.
    on the Form design, click on MobileNo and add Code to it's BeforeUpdate event:

    private sub MobileNo_BeforeUpdate(Cancel As Integer)
    Cancel = (DCount("1", "yourTableName", "MobileNo = '" & Me!MobileNo & "'")<>0)
    If Cancel Then
       Msgbox "Mobile number belongs to another person!"
    End If
    end sub
    Last edited by Aussiebear; 07-02-2022 at 09:02 PM. Reason: Added code tags to supplied code

Tags for this Thread

Posting Permissions

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