Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    64

    Unanswered: How to open form based on specific record only when combobox option is selected?

    I have a database for tracking patients that could have many diagnoses, all of different types. I want the user to select a diagnosis from a combobox and then a form automatically opens where you can add details specific to that diagnosis. So for each separate diagnosis option, I need a different form to open.

    I know how to open a form to a specific record with the button wizard and I know how to write code that opens a specific form depending on which option is selected, but I don't know how to use them together.

    If I'm adding a new diagnosis, then I don't need to use them together since I don't need to pull up a specific record, but I want the user to be able to double click any diagnosis that has already been entered, which will then pull up the corresponding form with that record so they can see the details of it.

    So how can I put code in the double click event of the combobox that basically says if the option selected is this, then open this form, if the option selected is that, then open that form, etc... and ALSO open the form to the corresponding record?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd suggest you add a command button tot he form
    using the design wizard instruct the button to open a form
    then modify the code (right click the command button, select build event)
    you then need to move that code to the combo box's on click event
    add an additional parameter to the openreport macro which identifies what waht patient you want to display..
    that would be, say 'PatientID = ' & mycomboboxname.value
    if patient ID was a string value then you'd nbeed to encapsualte the value with ' or " to tell the compiler where the value stops and starts
    that would be, say 'PatientName = "' & mycomboboxname.value & '"'
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2012
    Posts
    64
    Okay, here is the code I'm using in the double click event of the combobox:
    Code:
    Private Sub PDx_DblClick(Cancel As Integer)
    If Me.PDx = "Acute Ischemic Stroke" Then
      strForm = "frm_stroke"
    ElseIf Me.PDx = "Aneurysm (acute ruptured)" Then
      strForm = "frm_aneurysm"
    ElseIf Me.PDx = "Aneurysm (hx ruptured)" Then
      strForm = "frm_aneurysm"
    ElseIf Me.PDx = "AVM (hx hemorrhage)" Then
      strForm = "frm_avm"
    ElseIf Me.PDx = "AVM (no hemorrhage)" Then
      strForm = "frm_avm"
    End If
    DoCmd.OpenForm strForm, , , Me.[diagnosisID] = Forms![diagnosisID]
    End Sub
    In every form I want to open, there will be a corresponding diagnosisID field. But I can't include the form name because it could always be a different form.

  4. #4
    Join Date
    May 2012
    Posts
    64
    The first part of the code is working great! It's causing problems trying to open to a specific record...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •