Link to home
Start Free TrialLog in
Avatar of STEVE PERRY
STEVE PERRY

asked on

compare values and send alert

Have data in table
i need an way to alert me when the data is compare

for best example i have table tdata
in tdata field A have value ABCD , EFGH,  KLMN
is for example ABCD is identify  need an alert me

any idea??
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

you need to tell us which environment you want so that it will alert you accordingly?

let's say in an Access form, you can try use Dcount function:
if DCount("*", "tdata", "A = 'ABCD' ") > 0 then
    msgbox "Alert me... "
end if

Open in new window

will this make sense to you?
Avatar of STEVE PERRY
STEVE PERRY

ASKER

Ryan Chong
tnks !! good friend !

have formDATA
but how i put that code to work in ??
yes make sense ! to me
but how implement it ?
you can try to use the Form_Current() event in your form accordingly.

(image copied from Internet)
User generated imagein the VBA code, try paste above codes accordingly into Form_Current() event.
Ryan Chong

because  a situation in here
the value from fieldA comes from an expression in an query
ok, the DCount function should work well for query as well...

did you encounter any errors so far?
HAVE PROBLEMS
BECAUSE IS WORKING WITH EVRY RECORD NO JUST THE VALUE IM LOOKING FOR!
can you explicitly tell us what you intend to show/ how will it be shown when:

1. one record is detected that met the criteria
2. multiple records are detected that met the criteria
Ryan Chong
heres is an sample
when
one ofthe code is set i need an alert

but is working with all the record no just the trigger record!
DATASAMPLE.accdb
Ryan Chong
DO I EXPLAIN GOOD ?
I will have a look later as there's no MS Access installed in my current working machine.
thanks very much good friend !
by the way Ryan Chong

if i have an number field like 708 or 600
and i want just tke the cero from thet number  to be show in other field
is that possible ?
>>but is working with all the record no just the trigger record!
so i guess you only want to check if the "current record's AB field = 78 ?

if yes, then you can try like:
Private Sub Form_Current()
    If AB.Value = 78 Then
        MsgBox "Alert me this code is on "
    End If
End Sub

Open in new window

>>and i want just tke the cero from thet number  to be show in other field
ok, so if field1 contains 708, what you want to show in field2 ?
DATASAMPLE_b.accdb
Ryan Chong

thanks my good angel!

if field is 708 i just want the 0 be in other field2
but cero can be in any code
i mean could be 708, 078, 870 ect....
>>if field is 708 i just want the 0 be in other field2

will this field2's value be saved in your table or just for display purposes in your form?
Ryan Chong
be saved in table
>>if field is 708 i just want the 0 be in other field2
I guess the "field" refers to "DATA" field?

I have made the following changes accordingly.

1. Add a sample field called "Field2" in Table1
User generated image2. Update the Query1
User generated image3. Add Field2 into form FRM_DATA
User generated image4. Add the After Update event for the field "DATA" in form FRM_DATA
Private Sub DATA_AfterUpdate()
    Field2.Value = IIf(InStr(1, DATA.Value, "0", vbTextCompare) > 0, "0", "")
    Form.Refresh
End Sub

Open in new window

DATASAMPLE_c.accdb
Ryan Chong
Private Sub Form_Current()
    If AB.Value = 78 Then
        MsgBox "Alert me this code is on "
    End If
End Sub

Open in new window



have a question in here

have so many values will be a long list
there's an way to read it from an table or query
for example i mean the 78 89 90 ect..
the code i need to
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ryan Chong

Private Sub DATA_AfterUpdate()
    Field2.Value = IIf(InStr(1, DATA.Value, "0", vbTextCompare) > 0, "0", "")
    Form.Refresh
End Sub

Open in new window


Is working but one issue here
i have an table with data  already
this sub is working for the new data put in

theres an way to have the same result
but with the data already in the table ?
>>theres an way to have the same result
>>but with the data already in the table ?

yup, did you manage to see the sample I had uploaded in comment: ID: 40958636? It should able to handle existing records as well.
Ryan Chong
I Test it from comment: ID: 40958636

could you please give an check?


i change some  numbers to have 0 value already in the table
taht way it don't work

is because i have  data alredy in with a lot of recods
and i will have to retype one by one
will be difficult
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ryan Chong

That's Great !

let me try it..
Ryan Chong

UPDATE query is working great !!
but still with one issue
with the AB field this is woking like you say an that's fine

but i will need compare the AB field from table1
to code field table2

is that posible?
DATASAMPLE_b.accdb
>>but i will need compare the AB field from table1
>>to code field table2

sure, that's feasible. Can you give us an example how you want it to be done?

(sorry, I not yet check your attached db in comment: ID: 40961127)
Ryan Chong

don't know how to do it

but i need compare values from FIELD AB TO
VALUES IN tables2 if is in an message shoul alert
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ryan Chong,


IS WORKING  GREAT !!

you my master !
glad that i could make some helps cheers!
Ryan Chong

keep on the good !
i will miss you !

i have others questions
can we keep here ?
if you still have a series of questions, I guess it's better to create other posts in case i'm busy and not able to help cheers
THE BEST!