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

SendReport using value in table

P: 8
Platform: Access 2003

I have a table that has one record, need to pull the EmailAddress field to set as a value for a SendReport Command. I have searched for examples on line as to how to do this with no success.

I was able to create the RS and didn't get any errors, but when I tried to view the value of the email field, it gave me a wrong number of properties/arguments error.

Unfortunately I deleted the source code out of frustration, so I can't post it.

If anyone can help, I would greatly appreciate it.

Thanks

jm420a
Jul 25 '08 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
Hi. If all you need to do is to return one value it is far simpler to use DLookup to do so:

Expand|Select|Wrap|Line Numbers
  1. your_var = Dlookup("[name of e-mail field]", "[name of table]")
For the recordset version - which I include solely for completeness - the code is along the lines of

Expand|Select|Wrap|Line Numbers
  1. Dim RS as DAO.Recordset
  2. Set RS = CurrentDB.OpenRecordset("[name of table]")
  3. your_var = RS![name of e-mail field] ' this would fail if the recordset was empty
  4. RS.Close
This uses a Data Access Object (DAO) recordset which is the native Access recordset type. To use DAO ensure that a reference to the DAO object library is set - from the VB editor select Tools, References and tick Microsoft DAO 3.6 Object Library (or later) if not already selected.

As background on why this matters, when Access 2003 was released the default recordset type became the more general ADO (ActiveX Data Objects) type, which differs from DAO in some of its properties and method calls. and it is a reasonable bet that the error you experienced was as a result of a clash between the two different types of recordset methods. Hence the need to qualify recordset declarations with DAO or ADODB to avoid confusion, and to ensure the DAO object library is ticked when using this type of recordset.

-Stewart
Jul 26 '08 #2

Post your reply

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