jeff,
just a heads up....
i changed the ApplyEdits property of the switchboard to 'Yes' so as to allow
me to edit/modify the combobox i set on it which allows the user to select a
'Patient Number' from a RowSource that uses a SQL query on the value of it in
the Registration table.
also, i added this
DoCmd.ApplyFilter , "Me.[Patient Number] = " & [Forms]![Command and Control
Center]![SelectPatient]
to the OnOpen property of a form (in this case, the 'Diagnostic' tests form).
and ..... it compiles but seems to not work.
hmmmmm?
Hi Ted,
There really are countless ways to handle this, but I will present just
one method. Feel free to experiment with other techniques.
Follow these directions on a backup.
Assumptions:
- Your Switchboard form created by the wizard is called
Command And Control Center
- The form you wish to open is called Diagnostic
- The table on which the combo box is based is called
Registration
- The combo box on the form is called SelectPatient with
a Rowsource of something like:
SELECT Registration.[Patient Number] FROM Registration;
1. Create a new saved query called qryFilter with the following SQL:
SELECT Registration.*
FROM Registration
WHERE ((([Registration]![Patient Number])=[Forms]![Command And Control Center]![SelectPatient]));
2. Create a new Standard Module called modOpenForms
3. Copy/paste the following code into that module:
'***********Code Start**********
Public Sub OpenDiagnostic()
On Error GoTo ErrorPoint
If IsNull(Forms![Command And Control Center]!SelectPatient) Then
MsgBox "Please select a Patient Number from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient?"
Else
DoCmd.OpenForm "Diagnostic", , "qryFilter"
End If
ExitPoint:
Exit Sub
ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Sub
'***********Code Start**********
Why do we need the module?
It is necessary if you wish to continue using the Switchboard Manager
created form.
4. Compile the code, save, and close the module.
5. Launch the Switchboard Manager Wizard. To open the
Diagnostic form, instead of just using the "Open Form" option
you need to use the "Run Code" option. Select that and
then enter OpenDiagnostic in the Function Name area.
This tells the wizard that when the form option is pressed,
use the code we just created to open the form.
6. Close the wizard and then test. If no selection is made
in the combo box, then a message box is displayed and
the form does not open. If they choose a Patient Number
and then press the button on your main form, then the
Diagnostic form opens with a Filter applied that matches
the combo box selection. Clicking the Remove Filter
button on the Toolbar will show all the records if the
user decides to do that.
Hope that is what you are looking for. Make any
modifications to suit your desire.