Gustav Brock
gustav at cactus.dk
Tue Jan 28 11:47:33 CST 2014
Hi John
These are strings:
sfrmSurveys.LinkMasterFields = "txtIdentifier"
/gustav
-----Oprindelig meddelelse-----
Fra: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] På vegne af John Clark
Sendt: 28. januar 2014 18:30
Til: 'Access Developers discussion and problem solving'
Emne: [AccessD] Code Help for subforms
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"