Solved i want code,,Filter code before saving (1 Viewer)

SalmanZeiad

Member
Local time
Tomorrow, 00:25
Joined
Oct 30, 2017
Messages
112
I want a code that filters when entering the any part (word) of company name and there was a name saved by part of the company name that warns me with a message before saving or not

Example
Salman Computer Company
Salman For Computer
 

ebs17

Well-known member
Local time
Today, 23:25
Joined
Feb 7, 2020
Messages
1,949
Code:
If Instr(1, AnyText, AnyPart) > 0 Then    ' there is anything
 

SalmanZeiad

Member
Local time
Tomorrow, 00:25
Joined
Oct 30, 2017
Messages
112
can you see this @gazman and do it
 

Attachments

  • Database2.accdb
    480 KB · Views: 62

Gasman

Enthusiastic Amateur
Local time
Today, 22:25
Joined
Sep 21, 2011
Messages
14,317
can you see this @gazman and do it
No, you will never learn anything if someone else does it for you. :(

Look at the syntax and apply it, though TBH I think you need a DCount() for what you are asking. :unsure:
Test if the result is > 0

Code:
dcount("*","Testtransactions", "Description like '*" & tt & "*'") > 0

Where Description is the field you are searching and tt is the text you are loking for.

Those are just the names I had to use in my system in the imemdiate window.
Wlak through your code to check it. Use it on the Change event of the control.
 

SalmanZeiad

Member
Local time
Tomorrow, 00:25
Joined
Oct 30, 2017
Messages
112
No, you will never learn anything if someone else does it for you. :(

Look at the syntax and apply it, though TBH I think you need a DCount() for what you are asking. :unsure:
Test if the result is > 0

Code:
dcount("*","Testtransactions", "Description like '*" & tt & "*'") > 0

Where Description is the field you are searching and tt is the text you are loking for.

Those are just the names I had to use in my system in the imemdiate window.
Wlak through your code to check it. Use it on the Change event of the control.

Thank u very much<<<all is DONE
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:25
Joined
Sep 21, 2011
Messages
14,317
Thank you and I want to learn..
I tried the dcount function but it only works for matching if full name is entered
No it does not.
If you use Like and surround your control value with * (as I have done) then it will pick up anything that has that string.

So it will pick up Salma from alm
 

SalmanZeiad

Member
Local time
Tomorrow, 00:25
Joined
Oct 30, 2017
Messages
112
Please mark it solved then, button top right of the thread.
OK thank you,,

last ask,,,
If DCount("*", "Suppliers", "SuppName like '*" & tt & "*'") > 0 Then
If MsgBox("Duplicated Full Or Part?", vbQuestion + vbYesNo, "!!") = vbNo Then
''SuppName.BackColor = vbRed
Me.SuppName.Undo
Cancel = True
End If
End If

how can i grab the full name that`s saved and show in msgbox
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:25
Joined
Sep 21, 2011
Messages
14,317
Would need to use DLookup() instead and show the result of that.
Be aware you will get Null if name not found with DLookUp.

tt was just a name I give to a variable to use, short and sweet, you use the control name.?
 

Users who are viewing this thread

Top Bottom