Need to read one record - Is there an alternative to using RecordS

B

Brad

I need to simply read one record from a single table in Access using VBA.

Is there an alternative to using a RecordSet?

Is there a simpler method that doesn't require as many lines of code?

Thanks,
Brad
 
P

Philip Herlihy

Brad said:
I need to simply read one record from a single table in Access using VBA.

Is there an alternative to using a RecordSet?

Is there a simpler method that doesn't require as many lines of code?

Thanks,
Brad


Read about the Dlookup function in Help.

Phil, London
 
J

Jeff Boyce

Brad

Do you know which record? Do you have criteria to help you select that "one
record"?

Or are you looking for any record, chosen at random?

More info, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

Brad

Jeff,

Thanks for your help.

Yes, I know the key for the one record. I can make the RecordSet method
work, it just seems like a lot of lines of code for retrieving a single
record.

Thanks again,
Brad
 
A

Albert D. Kallal

Brad said:
I need to simply read one record from a single table in Access using VBA.

Is there an alternative to using a RecordSet?

Is there a simpler method that doesn't require as many lines of code?

I count two lines here:

dim rstData as dao.RecordSet

set rstData = currentdb.OpenRecordSet("select * from tblCustomer where id =
123")

That's not really a lot of code...is it?
 
B

Brad

Albert,

I guess you are right. Two lines aren't terrible.

Being a fairly new Access user, I am still adjusting to using RecordSets to
read data while I can add a row with just one statement. I was just
wondering if I was missing something, such as a way to read one record
without using a RecordSet.

Thanks for your feedback.


Brad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top