Use DLookUp?

O

Outatym

I need a certain check boxes on a form to be checked if the corresponding
data is present in a table.

I.E. if the applicant type is a corporation, then the corporation checkbox
will be checked. I will need to pull this information from applicationinfo
table and then the applicanttype field.

How do I go about doing this? If statements and dlookup?

Thanks,
Chris
 
M

Michel Walsh

just 'bind' the checkbox to something like (control source property of the
check box):

= DCount("*", "applicationinfo",
"applicanttype=FORMS!FormNameHere!applicanttype )


since a 0 will mean it is not found, and 0 is also false, or uncheck;
anything else that 0 means it is found, which is also true, or check.




Hoping it may help,
Vanderghast, Access MVP
 
O

Ofer Cohen

Try something like

Me.CheckBoxName =
(DlookUp("applicantFieldNameInTable","TableName","FieldToCheck = " =
Me.FieldNameInForm) & "" = "corporation" )

Please check help on DlookUp, if you need more help I'll need the name of
the fields involved and the type of each field
 
A

Al Campagna

Chris,
You shouldn't have to... that's redundant.
If you're already signifying that the applicant is "Corporation" then it's unnecessary
to also have a T/F check box to say the same thing.
Any subsequent form, query or report could find "Corporation" in Type as easily as
chkCorporation = True.

If you must... use the AfterUpdate event of ApplicationType...
Private Sub ApplicantType_AfterUpdate()
If ApplicantType = "Corporation" Then
chkCorporation = True
Else
chkCorporation = False
End If
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
O

Outatym

I understand, but they applicanttype field will have multiple values. For
instance: corporation, partnership, proprietorship, LLC...etc.

The form has each of these checkboxes and must be checked according to what
is in the applicanttype field for that record.

Would this code work for that?
 
O

Outatym

Thanks for the insight.....it worked like a charm.

t seems like the simplest problems can be the hardest to think through.

Thanks again!
 
A

Al Campagna

Outatym,
I still maintain that this is not necessary. It does not matter that Type can have
more than one value. Type = "Corporation" will find Corporation types, and Type =
"Partnership" will find all Partnership records... without having to have a "redundant"
check field for each type.

Can you imagine an Address database where there was a field AND checkbox for each City
entry? Each State entry? They have different values too. Would you do that?? Of
course not...
What happens when you add another Type? You'll have to redesign all your queries,
forms, and reports to add the New Type check box.
Even though I gave you a solution... what you're doing is incorrect. If you don't
correct that now, you'll pay the price down the road...
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Top