By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Search Records in VBA

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

Expand|Select|Wrap|Line Numbers
  1. DoCmd. SearchForRecord acActiveDataObject, "tblIV", acFirst, patientID
  2.  
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).
May 19 '08 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,638
I'm trying to search and display an record to a form using VBA Coding. here is what i have so far.

Expand|Select|Wrap|Line Numbers
  1. DoCmd. SearchForRecord acActiveDataObject, "tblIV", acFirst, patientID
  2.  
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 Programmatically
May 20 '08 #2

100+
P: 158
Thanks worked like a charm!
May 20 '08 #3

NeoPa
Expert Mod 15k+
P: 31,494
Have you considered simply applying a filter to the form that only allows the record you want?
May 21 '08 #4

missinglinq
Expert 2.5K+
P: 3,532
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)>
May 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.