Results 1 to 3 of 3
  1. #1
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183

    Problem with search function

    I have a problem with my database but I am not sure where I went wrong. Please see the attachment.

    I have a search form which searches/works fine until when I want to click on to the record that I am looking for, it gives me an error and won't open the right record.



    These codes were copied and paste from online examples,. I might have done wrong somewhere.

    Hope someone will be able to help me.

    Thank you .

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Have you run Debug>Compile?
    Have you step debugged?

    In my test the code errors in the SelectPatient function on the line:
    qry.Parameters("lngStudyID") = lngStudyID

    I modified the procedure to:
    Code:
    Private Function SelectPatient(ByVal lngStudyID As String)
        DoCmd.OpenForm "FrmAuditTool", , , "VisitID = " & Me.txtMetricsID
        DoCmd.Close acForm, "fdlgSearchPatient"
    End Function
    I also changed the RecordSource for FrmAuditTool to simply tblAudit. The qryFindMetricsID is not needed with these mods. If you want to leave this form open and repeat a search from fdlgSearchPatient, will need to expand the code to reset the form's filter criteria. That is what the original code is attempting to allow. I don't do this by altering query definition. I do this by setting the form's Filter and FilterOn properties. Otherwise, close the Audit form and start a new search.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by June7 View Post
    Have you run Debug>Compile?
    Have you step debugged?

    In my test the code errors in the SelectPatient function on the line:
    qry.Parameters("lngStudyID") = lngStudyID

    I modified the procedure to:
    Code:
    Private Function SelectPatient(ByVal lngStudyID As String)
        DoCmd.OpenForm "FrmAuditTool", , , "VisitID = " & Me.txtMetricsID
        DoCmd.Close acForm, "fdlgSearchPatient"
    End Function
    I also changed the RecordSource for FrmAuditTool to simply tblAudit. The qryFindMetricsID is not needed with these mods. If you want to leave this form open and repeat a search from fdlgSearchPatient, will need to expand the code to reset the form's filter criteria. That is what the original code is attempting to allow. I don't do this by altering query definition. I do this by setting the form's Filter and FilterOn properties. Otherwise, close the Audit form and start a new search.

    Thank you so much, June for all your help! You won't believe how happy I am right now!! Thanks!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-02-2011, 05:06 PM
  2. Creating a search function
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 12-30-2010, 02:03 PM
  3. Search function in forms
    By vCallNSPF in forum Forms
    Replies: 1
    Last Post: 03-14-2010, 06:17 PM
  4. search function
    By Eric1066 in forum Access
    Replies: 0
    Last Post: 10-23-2009, 10:23 AM
  5. search,view and open function
    By blurboy84 in forum Reports
    Replies: 0
    Last Post: 10-08-2009, 11:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums