Search Records in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jollywg
    New Member
    • Mar 2008
    • 158

    Search Records in VBA

    I'm trying to search and display an record to a form using VBA Coding. here is what i have so far.

    Code:
    DoCmd. SearchForRecord acActiveDataObject, "tblIV", acFirst, patientID
    tblIV is the name of the table i want to search in, and patientID is an integer variable that i have a value given to it in a different form that is being passed to this form (i know for a fact that the value is being passed correctly).
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Jollywg
    I'm trying to search and display an record to a form using VBA Coding. here is what i have so far.

    Code:
    DoCmd. SearchForRecord acActiveDataObject, "tblIV", acFirst, patientID
    tblIV is the name of the table i want to search in, and patientID is an integer variable that i have a value given to it in a different form that is being passed to this form (i know for a fact that the value is being passed correctly).
    You should definately benefit from reading this previous Tip of the Week:
    How to Find a Record Programmaticall y

    Comment

    • Jollywg
      New Member
      • Mar 2008
      • 158

      #3
      Thanks worked like a charm!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32636

        #4
        Have you considered simply applying a filter to the form that only allows the record you want?

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          This is a new command only appearing in Access 2007. It's always a good idea to include the version number when posting questions, but it's especially important when you're using this latest version, as many things are different in it and only a small subset of the members here are running it.

          As for the command you're using, the code you posted has a space between DoCmd. and SearchForRecord, which it shouldn't, and you really haven't stated what problem, if any, you're experiencing, which you really should always do.

          Although, as recently documented here on bytes, NeoPa's ESP is on fritz, his advice is well worth taking.

          Linq ;0)>

          Comment

          Working...