Avatar of CptPicard
CptPicard
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Check two values

Hi

I use Access 2010.

I need to make a label and image visible on a form if there are values in two specific fields within two separate tables.  If there are no values then the label and image will be invisible.

Basically the two fields are 'ContactID' and 'Complete'.  The ContactID is a text field and the 'Complete' field is a Yes/No field.

I have two forms - 'Form1' and 'Form2'.

In 'Form 1' I have two fields.  'ContactID' and 'Complete'.  I also have these fields in 'Form 2'.

When I open 'Form 1' I want to check if there's another 'ContactID' with the same ID in form2 and if it has the field 'Complete' ticked.  If it does, then it will display the label and img to show it's complete.  If it can't find the same 'ContactID' and the field 'Complete' isn't ticked, then it will not display the label and img.

Thanks for your help.
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
PatHartman

Forms don't store data.  Tables store data.  If the same record is displayed on two forms, it should be the same unless you look in the instant that someone is updating one of them.

To avoid confusing users, it is usually best to have only one form open at a time so I am not at all sure what you are trying to accomplish.  What is the purpose of having two forms open to the same record?
CptPicard

ASKER
There's two tables and two forms.

both table 1 and 2 share the same unique field called 'ContactID'.

So when I have my Form1 open which looks at the record source 'Table1', I want it to check if there's the same 'ContactID' and the 'Complete' tick box is checked in 'Table 2'.  If Table 2 does have the same ContactID and the Complete tick box is checked for this ContactID then I want form 1 to make the Complete label and image visible.  If Table 2 doesn't have the same ContactID and the Complete tick box ticked, then it will not display the label and image to show it's complete.
ASKER CERTIFIED SOLUTION
PatHartman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CptPicard

ASKER
That's exactly what I needed.  Thank you.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
CptPicard

ASKER
One problem though.  when there isn't anything in ContactID I get an error message.

Run-time error '3075':
Syntax error (missing operator) in query expression 'ContactID = '.
CptPicard

ASKER
Hope you can help?
PatHartman

If DLookup("TickBox","table2", "ContactID = " & Nz(Me.ContactID,0)) = True Then
    Me.lblComplete.Visible = True
    Me.Image.Visible = True
Else
    Me.lblComplete.Visible = False
    Me.Image.Visible = False
End If

Open in new window

I substituted 0 for null.  You shouldn't have an ID = 0 if it is an autonumber.  If 0 is a potential value, then you would need to use an If to avoid doing the DLookup().
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.