[AccessD] Code Help for subforms

John Clark John.Clark at niagaracounty.com
Tue Jan 28 11:30:25 CST 2014


Once again, I've been called in to help fix a program that was written by a user (i.e. non-programmer). The last one...two weeks ago...was written by a young lady who they sent to a $600 training class...yep, I learned all I know for $600, spent over a couple of days...
 
Anyhow, before I digress to much, the odd thing here is that it normally takes me about the same amount of time to fix these bad programs, as it would have to just write them myself in the first place. 
 
The one I am working on now has me a little perplexed. I had this brilliant idea and I'm having a bit of trouble pulling it off. I'm giving it just a bit and then I'm going to head another way w/it...but I'd like to pull this off if I could. 
 
It is for our health department, and this woman deals w/dental health. They track children's dental health, and they want this info to be there for all ages. There are 3 different surveys (questionnaires) based on their age...and they can end up w/a record for each survey...I believe multiples actually. 
 
So, what I wanted to do was have the surveys show up as sub-forms. Until the client's age was discovered, the subform control would be blank...I have a blank subform w/a message on it...then, depending on the age, the proper survey would fill in the subform control...I have a form designed for each survey. 
 
But, if I do this, I'm not sure how to link the subforms (i.e.. surveys) w/the proper client. this is what I have just done, but am getting an error...after first getting a request to enter a variable...
______________________________________________________________________________________________
Public Function AgeCalc()
 
If Not (IsNull(datFormDate)) Then
 
    If IsNull(datDoB) Then
        txtAgeYrs.Value = 0
    Else
        txtAgeYrs.Value = Age(datDoB, datFormDate)
        intMonths = Months(datDoB, datFormDate)
        txtAgeMos.Value = (Months(datDoB, datFormDate)) Mod 12
    
        Select Case txtAgeYrs.Value
            Case Is < 4
                sfrmSurveys.SourceObject = "frmSurvey1"
                sfrmSurveys.LinkMasterFields = txtIdentifier
                sfrmSurveys.LinkChildFields = lnk2Client
            Case Is < 18
                sfrmSurveys.SourceObject = "frmSurvey2"
                sfrmSurveys.LinkMasterFields = txtIdentifier
                sfrmSurveys.LinkChildFields = lnk2Client
            Case Is < 21
                sfrmSurveys.SourceObject = "frmSurvey3"
                sfrmSurveys.LinkMasterFields = txtIdentifier
                sfrmSurveys.LinkChildFields = lnk2Client
        End Select
        
    End If
 
End If
 
End Function
__________________________________________________________________________________________
 
 
The problem seems to be occurring at the 2nd line...the "LinkMasterFields"

Notice: This electronic transmission is intended for the sole use of the individual or entity to which it is addressed and may contain confidential, privileged or otherwise legally protected information. If you are not the intended recipient, or if you believe you are not the intended recipient, you are hereby notified that any use, disclosure, copying, distribution, or the taking of any action in reliance on the contents of this information, is strictly prohibited. Niagara County is not responsible for the content of any external hyperlink referenced in this email or any email. 
IF YOU HAVE RECEIVED THIS TRANSMISSION IN ERROR, PLEASE NOTIFY THE SENDER IMMEDIATELY BY EMAIL AND DELETE THE ORIGINAL MESSAGE ALONG WITH ANY PAPER OR ELECTRONIC COPIES. 
Thank you for your cooperation.


More information about the AccessD mailing list