A multiple option group

  • Thread starter Thread starter Bernd
  • Start date Start date
B

Bernd

Hi,
how can I implement in Access a multiple option group?
Exactly I would like to have the possibility to choose
multiple medicines for a patient selecting the box near
the category of medicine.After I would like to store the
selected medicines in an associated table.
Any idea?
Thanks
Bernd
 
Hi,
how can I implement in Access a multiple option group?
Exactly I would like to have the possibility to choose
multiple medicines for a patient selecting the box near
the category of medicine.After I would like to store the
selected medicines in an associated table.
Any idea?
Thanks
Bernd

The simplest way to do this would be to use a Subform based on the
patient-medications table; you could have a Combo Box on the subform
allowing a medication to be selected from the Medications table and
stored.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Bernd,
Drop your checkboxes onto your form. Then draw the frame
around them. This way you can check more than 1. Bind each
checkbox to a yes/no field in the form's record source.
This does break normal form rules.
To be more strict have an unbound form. Make a Save
button. The save will look at each checkbox and if the
value is -1, run an Insert query into a table that has
patientid, drugid.
A better way would be to have a listbox with multiple
select capabilities. This way you can add new drugs
without changing the form design. With the checkbox design
you can't add new drugs without adding new checkboxes.
Geof.
 
Thank you for you answer.
How can I implement a listbox with multiple select
capabilities?
Thanks
Bernd
 
Bernd,
Make and save a query such as Select MedsID, Medicine From
tblMeds Order by Medicine. Draw a list box on your form.
Assign the query to the row source of the listbox. On the
Other tab of the list box properties window, set the Multi
Select property to simple. To see how you might process
selected items, please have a look at Help in design mode
for the Selected property. Or place your cursor on the
Multi Select proerty line and press F1 and look for a
reference to the Selecetd property.
Good luck.
Geof.
 
Hi,
I did it! Now I can make a multiple select of the
medicine the patient uses, but how can I store the
multiple selection in my table. I've made the listbox and
a save button near them, but when I select the medicines
I need and I click on the button, nothing is stored in
the associated table. Any idea how I can solve this
problem?
Thanks
Bernd
 
Hi,
I did it! Now I can make a multiple select of the
medicine the patient uses, but how can I store the
multiple selection in my table. I've made the listbox and
a save button near them, but when I select the medicines
I need and I click on the button, nothing is stored in
the associated table. Any idea how I can solve this
problem?
Thanks
Bernd

A Subform (as suggested elsewhere in this thread) is easier to
implement; but if you really want the listbox approach, here's some
VBA code I use in a similar situation.

Private Sub cmdProcess_Click()
' Comments : Update the AnimalCondition table based on the
' selections in the unbound multiselect listbox lstHealthIssues.
' Newly selected rows will be added to the table, newly cleared
' rows will be deleted.
' Parameters: None
' Modified : 01/29/02 by JWV
'
' --------------------------------------------------
' Populate the AnimalCondition table with the selected issues
On Error GoTo PROC_ERR

Dim iItem As Integer
Dim lngCondition As Long
Dim db As DAO.Database
Dim rs As DAO.Recordset

' save the current record if it's not saved
If Me.Dirty = True Then
Me.Dirty = False
End If
Set db = CurrentDb
' Open a Recordset based on the table
Set rs = db.OpenRecordset("AnimalCondition", dbOpenDynaset)
With Me!lstHealthIssues
' Loop through all rows in the Listbox
For iItem = 0 To .ListCount - 1
lngCondition = .Column(0, iItem)
' Determine whether this AnimalID-HealthID combination is
' in the table
rs.FindFirst "[AnimalID] = " & Me.AnimalID & " AND " _
& "[HealthIssueID] = " & lngCondition
If rs.NoMatch Then ' this item has not been added
If .Selected(iItem) Then
' add it
rs.AddNew
rs!AnimalID = Me.AnimalID
rs!HealthIssueID = lngCondition
rs.Update
End If ' if it wasn't selected, ignore it
Else
If Not .Selected(iItem) Then
' delete this record if it's been deselected
rs.Delete
End If ' if it was selected, leave it alone
End If
Next iItem
End With
rs.Close
Set rs = Nothing
Set db = Nothing
Me.subAnimalCondition.Requery

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error " & Err.Number & " in cmdProcess_Click:" _
& vbCrLf & Err.Description
Resume PROC_EXIT

End Sub




John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top