table for assessments and a table that has a dropdown to fill in information
on each assessment for a family. Each family needs each assessment to show
up with related information. I imported all the families from another
program we work with.
will allow me to click a button and have all 31 assessments show up instead
of having to use the drop down to bring each one up?
you will need to know some Visual Basic. I feel like I am throwing darts at a target that is too big; I can through a dart in almost any direction and hit it. I need a more specific questions, so that I can gauge your knowledge level and your specific needs.
I built the form. I know very little vb code (mostly look at other stuff and
modify names, etc. to fit my program). The screen is currently Access
data-bound controls. The family info is in one table, the assessments are
pulled from another table, all the option information for the assessments are
saved to another table. I can sellect anything I want. I want to push a
button and have all 31 assessments show up at once for the family I'm in.
Then just the options have to be clicked on.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
There may be a way to do it using bound Access controls, but it's not
the way I would do it. Here is my suggestion:
1) Use an unbound form.
2) Populate the form with all of the checkboxes, etc. that you will
need to show all options.
3) Create a function that reads the current record of the main table,
and the associated records of the auxillary tables; create a user-
defined data structure to represent the combined record.
4) Create a function that updates the form with the data from the user-
defined data structure.
5) Create a function that saves the screen-input data to the user-
defined data structure.
6) Create a function that saves the data in the user-defined data
structure to the various tables.
Here is an example that you can use to pattern your own code:
In a public module:
Private Type Assessment
SocialSecurityNo As String
MedicalHome As boolean
DentalHome as boolean
LegalProblems as string
Education as string
End Type
Private Type Customer
Name as string
Address as string
HomePhone as string
SocialSecurityNo as string
End Type
In the form module:
Private db as dao.database
Private CurAssessment as Assessment
Private CurCustomer as Customer
Private bAssessmentFound as boolean
Private sub ReadCustomer
Dim rs as dao.recordset
Set rs=db.OpenRecordset("tblCustomer",dbOpenSnapShot)
If Not rs.eof
Rs.FindFirst "[SocialSecurityNo]=' " &
CurCustomer.SocialSecurityNo & " ' "
If Not rs.NoMatch then
CurCustomer.Name=rs!Name
CurCustomer.Address=rs!Address
CurCustomer.HomePhone=rs!HomePhone
Endif
Endif
rs.close
set rs=Nothing
End Sub
Private Sub ReadAssessment
Dim rs as dao.recordset
Set rs=db.OpenRecordset("tblAssessments",dbOpenSnapShot)
If Not rs.eof then
Rs.FindFirst "[SocialSecurityNo]=' " &
CurCustomer.SocialSecurityNo & " ' "
If Not rs.NoMatch then
CurAssessment.SocialSecurityNo=rs!SocialSecurityNo
CurAssessment.MedicalHome=rs!MedicalHome
CurAssessment.DentalHome=rs!DentalHome
CurAssessment.LegalProblems=rs!LegalProblems
CurAssessment.Education=rs!Education
bAssessmentFound=True
Else
bAssessmentFound=False
Endif
Endif
Rs.close
Set rs=Nothing
End Sub
Private sub DisplayCustomer
TxtCustomer=CurCustomer.Name
TxtAddress=CurCustomer.Address
TxtHomePhone=CurCustomer.HomePhone
End Sub
Private sub DisplayAssessment
chkMedicalHome=CurAssessment.MedicalHome
chkDentalHome=CurAssessment.DentalHome
txtLegalProblems=CurAssessment.LegalProblems
txtEducation=CurAssessment.Education
End Sub
Private Sub InputCustomer
CurCustomer.Name=txtCustomer
CurCustomer.Address=txtAddress
CurCustomer.HomePhone=txtHomePhone
End sub
Private Sub InputAssessment
CurAssessment.MedicalHome=chkMedicalHome
CurAssessment.DentalHome=chkDentalHome
CurAssessment.LegalProblems=txtLegalProblems
CurAssessment.Education=txtEducation
End Sub
Private Sub SaveAssessment
Dim rs as dao.recordset
Set rs=db.OpenRecordset("tblAssessments",dbOpenSnapShot)
If Not rs.eof then
Rs.FindFirst "[SocialSecurityNo]=' " &
CurCustomer.SocialSecurityNo & " ' "
If Not rs.NoMatch then
rs.Edit
Else
rs.AddNew
Endif
rs!SocialSecurityNo=CurCustomer.SocialSecurityNo
rs!MedicalHome= CurAssessment.MedicalHome
rs!DentalHome= CurAssessment.DentalHome
rs!LegalProblems= CurAssessment.LegalProblems
rs!Education= CurAssessment.Education
rs.Update
Endif
Rs.close
Set rs=Nothing
End Sub
Private Sub cmdSave_click
If CurAssessment.SocialSecurityNo<>"" then
InputAssessment
SaveAssessment
ClearEditScreen
EditDisable
Endif
End sub
Private Sub cmdRetrieveCustomerFile
CurCustomer.SocialSecurityNo=txtSocial
If CurCustomer.SocialSecurityNo<>"" then
ReadCustomer
ReadAssessment
EditEnable
Endif
End Sub
Private Sub EditEnable
chkMedicalHome.enabled=True
chkDentalHome.enabled=True
txtLegalProblems.enabled=True
txtEducation.enabled=True
End Sub
Private Sub EditDisable
chkMedicalHome.enabled=False
chkDentalHome.enabled=False
txtLegalProblems.enabled=False
txtEducation.enabled=False
End Sub
Private Sub ClearEditScreen
txtSocial=""
chkMedicalHome=False
chkDentalHome=False
txtLegalProblems=""
txtEducation=""
End Sub
To make this example work, you will need to supply a form with the
appropriately named checkboxes, textboxes, and command button.
Everything that starts with "txt" references a textbox; everything
that starts with "cmd" references a command button; everything that
starts with "chk" references a checkbox. When you creat the screen
controls chkMedicalHome, chkDentalHome, txtLegalProblems, and
txtEducation, set their Enabled property to false. They will become
enabled once a valid social security number is entered and again
disabled once the record is saved. I haven't tested this code, so
there may be an error or ommision somewhere. The basic principles are
sound, and you should be able to figure out what each part is supposed
to accomplish. Basically, the Social Security number is the key.
Type in a customers Social Security number and click on "Retrieve
Customer File". If it finds data, it will display it. If it doesn't,
the fields on the screen will be left blank so that the user can enter
the data. When the user clicks on "Save" then the assessment will be
saved. If you want to add or edit customers, some additional coding
will be required.