Link to home
Start Free TrialLog in
Avatar of powerman9
powerman9Flag for United States of America

asked on

How to use a conditional value from a subform in Access 2016 database using Access VBA

Hi! I'm having some trouble with some code I am trying to put together. I am very much a beginner, so this could be a really simple problem. Basically, I have a subform that uses information from the parent form and and another subform to create an email. I am not having any issues generating the email, but what I want to do is create body text using a text field in the subform only if a related field is "true" (it's a yes no field).  Right now I have

  l_Msg.HTMLBody = "<!DOCTYPE html><body style=""font:normal normal normal 11pt/11pt calibri;"">" & _
  "<div>Hi" & " " & Me!PitchCastingFirstName & "!<br><br>" & _
  "I'd like to submit" & " " & UCase((Parent!FirstName) & " " & Nz(Parent!LastName)) & " for the role of " & Nz(Me!PitchRole) & "." & _
  " " & Parent!ClientPitchParagraphTbl_subform.Form!PitchParagraph & _
  "</div></body></html>" _

Open in new window


I want Parent!ClientPitchParagraphTbl_subform.Form!PitchParagraph to only be used if the related field "active" is set to "true".  Do I have to create a string or is there a simple declaration?

Thanks in advance.
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Where is your related "active" field? Is it on the main form, or on one of those subforms?
Avatar of powerman9

ASKER

It is on the subform.
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America 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
That worked perfectly. Thank you so much!
Clear, fast and concise answer. Thank you, Scott!