Search as you type question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sk88
    New Member
    • Dec 2011
    • 11

    Search as you type question

    I have a search form which has the SEARCH AS YOU TYPE function.

    Now when I double clicked on to the searched item, it will show me the main form with all the information that has been saved including the subform but it does not take me directly to the specific record in the subform.

    For instance, In my main form, I have an option to choose A.M., LUNCH or P.M.

    Accordingly, whichever one I click, it will be visible as a subform. For example, if I click A.M., the A.M. SUBFORM will be visible. If I click LUNCH, the LUNCH SUBFORM will be visible and the rest hidden.

    How do I link subform to the search form so that if I click on to MR.A’s form for LUNCH time only, it will open up the main form with LUNCH subform.

    Sorry, I know this is confusing. I hope someone understands me!
    Thanks!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    In your code where you open the form, use the WHERE parameter to filter for the record you want.

    Comment

    • sk88
      New Member
      • Dec 2011
      • 11

      #3
      Sorry Rabbit.
      I did not quite understand.
      I do have vb codes for setfilter.

      Did you mean I add another line to it to state which record?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Not another line. I assume you're using a DoCmd.OpenForm to open the form. That method has an argument that you can use to specify a where clause so you can open it to that record.

        Comment

        • sk88
          New Member
          • Dec 2011
          • 11

          #5
          I still did not really get what you are trying to say. I have attached a copy of my work here. I hope you can help me out.

          Basically, when I click on to EDIT a record , the subform does not match what I am looking for.
          I am using a DoCmd.OpenForm


          Thanks Rabbit!
          Attached Files

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Can you post the code instead?

            Comment

            • sk88
              New Member
              • Dec 2011
              • 11

              #7
              sure...
              this is what I have for EDIT command
              Code:
              Private Sub Command0_Click()
              
                  
                  DoCmd.OpenForm "frmAuditTool", , , "StudyID=" & StudyID
                  
              
              
              End Sub

              Comment

              • sk88
                New Member
                • Dec 2011
                • 11

                #8
                I am not sure if you would like to see this too,,
                Code:
                Private Function SelectPatient(ByVal lngStudyID As String)
                
                    DoCmd.OpenForm "FrmAuditTool", , , "StudyID = " & Me.txtMetricsID
                    DoCmd.Close acForm, "fdlgSearchPatient"
                
                End Function
                
                
                
                
                Private Sub Form_Open(Cancel As Integer)
                ' Make sure filter/order is off, so that it will open faster
                #If Not CC_Debug Then
                On Error GoTo ErrProc
                #End If
                    
                    ClearFilter
                    
                ExitProc:
                    Exit Sub
                ErrProc:
                    Err.Msg Err, Err.Description, Err.Source
                    Resume ExitProc
                End Sub

                Comment

                • Rabbit
                  Recognized Expert MVP
                  • Jan 2007
                  • 12517

                  #9
                  I think I see now. I missed the subform part. You can pass which one you chose in the OpenArgs parameter and then use that to make the correct subform visible using the OnLoad event of the form.

                  Comment

                  • sk88
                    New Member
                    • Dec 2011
                    • 11

                    #10
                    Originally posted by Rabbit
                    I think I see now. I missed the subform part. You can pass which one you chose in the OpenArgs parameter and then use that to make the correct subform visible using the OnLoad event of the form.

                    Thank you again Rabbit

                    this is what I added to my existing code
                    Code:
                    Private Sub Command0_Click()
                    
                        DoCmd.OpenForm "frmAuditTool", , , "StudyID=" & StudyID, OpenArgs:="Parameter (s)"
                    
                    End Sub
                    I have never used OpenArgs. Could you please help.
                    You mean in OnLoad, I use code like:
                    Code:
                    Me.CopyFrmAuditTool.visible = true
                    and thats it? Do I have to add anything to it?

                    Comment

                    • Rabbit
                      Recognized Expert MVP
                      • Jan 2007
                      • 12517

                      #11
                      Well, I thought you wanted to make a certain subform visible depending on whether they clicked on am, lunch, or pm? That's what should be passed in OpenArgs. Then in the OnLoad, you can check what the OpenArgs is and make the correct subform visible.

                      Comment

                      • sk88
                        New Member
                        • Dec 2011
                        • 11

                        #12
                        what should I put under parameter?

                        "A.M. or LUNCH or P.M." ?

                        Comment

                        • sk88
                          New Member
                          • Dec 2011
                          • 11

                          #13
                          OK.. let me try again

                          Comment

                          Working...