PDA

View Full Version : Dlookup



RASHID
07-02-2022, 06:35 PM
Hi
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???.

arnelgp
07-02-2022, 07:27 PM
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