Use of boolean in If-Then

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Parent form with several subforms (located in tabs). I was able to
see/hide fields in one form based on the values in another form using code
like this:

Private Sub ImmunizationHistory_GotFocus()
If Forms![SPCA]![PetInfo].Form!PetType = "Dog" Then
Me.CatRunnyEyesNose.Visible = False
Me.CatFleaCollarHarness.Visible = False
End If

I've tried to replicate this procedure in another subform that tries to
examine boolean (yes/no) fields using code like this:

If Forms![SPCA]![Services].Form![Rabies] = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
End If

When I run the program, however, I get the following message: "Microsoft
Office Access, can't find the field 'SERVICES' referred to in your
expression." This subform was under a tab named "SERVICES" so I renamed the
tab 'APPLICATION' and have confirmed that the form name I'm trying to call is
"Services"...I'm stumped. There is a table named 'Services' but I can't
imagine this being the problem. Any suggestions? (Also, is there anything
special I need to know about referrring to subforms that are parked under a
tab?).
 
I've tried to replicate this procedure in another subform that tries to
examine boolean (yes/no) fields using code like this:

If Forms![SPCA]![Services].Form![Rabies] = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
End If

When I run the program, however, I get the following message: "Microsoft
Office Access, can't find the field 'SERVICES' referred to in your
expression." This subform was under a tab named "SERVICES" so I renamed the
tab 'APPLICATION' and have confirmed that the form name I'm trying to call is
"Services"...I'm stumped. There is a table named 'Services' but I can't
imagine this being the problem. Any suggestions? (Also, is there anything
special I need to know about referrring to subforms that are parked under a
tab?).

The tab control is completely irrelevant, and is not used in any way
in referencing controls.

What's important is the Name property *of the Subform control* - the
box which *contains* the subform. In form design view on the mainform
click the edge of the subform (not within it); there should be a
rectangle highlighted, outlining the subform.

The syntax would be

Forms!SPCA!subformcontrolname.Form!controlname

I'm intrigued that you're developing a database for an SPCA animal
shelter - I've been working with the Los Angeles SPCA for several
years on one. Contact me at jvinson <at> wysard of info <dot> com
(remove all blanks and substitute punctuation) if you're interested in
discussing it.

John W. Vinson[MVP]
 
Yaaaaay! That did it. Somewhere along the line the form was renamed
Services1 (probably because I'd used Services elsewhere or something); I
didn't know that until I clicked on the frame as you'd suggested. I changed
the name and now all seems to be working fine. Many, many thanks.
--
SHB


John Vinson said:
I've tried to replicate this procedure in another subform that tries to
examine boolean (yes/no) fields using code like this:

If Forms![SPCA]![Services].Form![Rabies] = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
End If

When I run the program, however, I get the following message: "Microsoft
Office Access, can't find the field 'SERVICES' referred to in your
expression." This subform was under a tab named "SERVICES" so I renamed the
tab 'APPLICATION' and have confirmed that the form name I'm trying to call is
"Services"...I'm stumped. There is a table named 'Services' but I can't
imagine this being the problem. Any suggestions? (Also, is there anything
special I need to know about referrring to subforms that are parked under a
tab?).

The tab control is completely irrelevant, and is not used in any way
in referencing controls.

What's important is the Name property *of the Subform control* - the
box which *contains* the subform. In form design view on the mainform
click the edge of the subform (not within it); there should be a
rectangle highlighted, outlining the subform.

The syntax would be

Forms!SPCA!subformcontrolname.Form!controlname

I'm intrigued that you're developing a database for an SPCA animal
shelter - I've been working with the Los Angeles SPCA for several
years on one. Contact me at jvinson <at> wysard of info <dot> com
(remove all blanks and substitute punctuation) if you're interested in
discussing it.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top