[AccessD] Code Help for subforms

Jim Lawrence accessd at shaw.ca
Tue Jan 28 13:58:31 CST 2014


Hi John:

Here is a quick overview on coding this product.

One, generally when there is choices made or can be made on a combo box, a choice like "Please enter..." would be displayed. This fills the requirement for the program but lets the programmer, you, know that the form is not complete yet and then you can manage it. Some combo boxes and fields can turned off (locked) until there is sufficient information entered in other fields

Two, when there are a more than one table populating a form and not completing the form in its entirety causes a key error, then use a substitute or temporary key, one which lets you know, as the programmer that the particular record has not been completed. This will allow you to manage displays and reports by isolating incomplete recordsets. The temp key holds a record's position like a bookmark and when sufficient information has been added, to the form, the permanent key replaces the temp key. This all has to be done program wise but it is not difficult.

Aside: Of course this goes against the training of many developers. Changing keys on the fly is held as sacrilegious by many programmers and I have watched while a million dollar Oracle project failed because its designers could not or would not comprehend that concept. 

Jim     



----- Original Message -----
From: "John Clark" <John.Clark at niagaracounty.com>
To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com>
Sent: Tuesday, January 28, 2014 9:30:25 AM
Subject: [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"

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.

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list