I'm assuming that both TableA.ID and TableB.ID are shown on your form.
If that is the case, add this code to the After Update event for both TableA.ID and TableB.ID fields:
[tt]
If (Me![TableAID]=Me![TableBID]) Then
Me![LabelName].Caption= "TrueText"
Else
Me![LabelName].Caption= "FalseText"
End If
[/tt]
You may also want to put the code in the On Current event for the form. That way it will evaluated when you open the form or change records.
Obviously, you now have the code in three places, which suggests using a Private Sub in your form module and calling that sub from each event. Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
Thanks for that Jonathan. However, only Table A is on the form, Table B is not. Therefore, I must write a module that references Table B? Am I right? Where would you suggest I find more information on modules? Or more on VBA for that matter...thanks.
OK, so Table B has a bunch of records in it, right? Each record has a unique ID associated with it. Is there another field that ties the two records together? Otherwise, how do you know which ID in table B to compare with the ID for the Table A record that is displayed by your form? Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
You're correct, it's the ID that ties both the tables together. However, do u mean show Table B in the form as well? Then write a sub that checks whether the ID for Table A and Table B match? If they match, label shows "TrueText", if no match, then label shows "FalseText"
Thanks.. Is this the best way? What I was asking earlier is do we create a module that checks for these? If we do, where can I find an example of code?
You totally lost me. If the ID # is the linking field (in other words, Record A is linked to Record B if and only if ID for Record A = ID for record B) then of course TableA.ID = TableB.ID. Can you give me the complete structure of table A and table B so I can understand what you're trying to do?
Maybe you're trying to find the record in Table B for which the ID is equal to the record in Table A that is displayed in your form. That's different from what you asked, but I'm really confused. I think the structures of the two tables will be helpful. Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
Thanks for the reply Jonathan.
Here's more notes:
Table A has ID and Name
Table B has ID and Name
LabelC is the label to show if "truetext"
Table B is a linked table from another database
I need explanation from scratch actually, which controls to drop on the form, writing the code and making LabelC show if the TableA.ID = TableB.ID
If anyone knows of a microsoft knowledge base article or another article posted before on this topic, please let me know. Thanks.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.