473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Setting Row Source via VBA

Hi,

I have the following code which produces an excel doc with the
required info -

Dim recordSetTest As DAO.Recordset
Set recordSetTest = CurrentDb.OpenRecordset("Select tblTest.Test,
tblTest.Name, tblTest.TestStatus from tblTest")

excelRowPosition = 1
recordSetTest.MoveFirst
Do While Not recordSetTest.EOF
excelWorkSheet.Cells(excelRowPosition, 1) =
recordSetTest.Fields("Test")
excelWorkSheet.Cells(excelRowPosition, 2) =
recordSetTest.Fields("Name")
excelWorkSheet.Cells(excelRowPosition, 3) =
recordSetTest.Fields("TestStatus")

excelRowPosition = excelRowPosition + 1
recordSetTestCase.MoveNext 'move to next record in recordset
Loop

The problem is that TestStatus stores an index to a row in a second
table, where I store TestStatus values. This table has two fields -
Index and a text description of the status. Therefore, I would like to
print this status discription in the excel document rather than the
index, for each row in Test. How might I go about doing this?

Thanks for your help,

Barry.

May 9 '07 #1
1 3016
On 9 May 2007 07:20:25 -0700, bg***@yahoo.com wrote:

Rather than selecting from a table, select from a new query you will
create, where you join the two tables on the TestStatus field. Your
code will remain virtually unchanged:
Set recordSetTest = CurrentDb.OpenRecordset("Select * from qryTest")

Also be sure to do the same in the Relationships window, and enforce
the relationship.

-Tom.

>Hi,

I have the following code which produces an excel doc with the
required info -

Dim recordSetTest As DAO.Recordset
Set recordSetTest = CurrentDb.OpenRecordset("Select tblTest.Test,
tblTest.Name, tblTest.TestStatus from tblTest")

excelRowPosition = 1
recordSetTest.MoveFirst
Do While Not recordSetTest.EOF
excelWorkSheet.Cells(excelRowPosition, 1) =
recordSetTest.Fields("Test")
excelWorkSheet.Cells(excelRowPosition, 2) =
recordSetTest.Fields("Name")
excelWorkSheet.Cells(excelRowPosition, 3) =
recordSetTest.Fields("TestStatus")

excelRowPosition = excelRowPosition + 1
recordSetTestCase.MoveNext 'move to next record in recordset
Loop

The problem is that TestStatus stores an index to a row in a second
table, where I store TestStatus values. This table has two fields -
Index and a text description of the status. Therefore, I would like to
print this status discription in the excel document rather than the
index, for each row in Test. How might I go about doing this?

Thanks for your help,

Barry.
May 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tumzadoc | last post by:
Hi I'm writing a software that prints receipts using a thermal printer. I don't want my user to set up the paper source i want to do it in my code, how do i do that? Much Luv Tumzadoc
3
by: CSDunn | last post by:
Hello, I currently have an Access 2003 ADP Report/Subreport set up in which I have 12 subreports in a single main report that are located in a group header called 'PermnumHeader' (Permnum would be...
1
by: KC | last post by:
Hi, I created a new event log source and log and user WriteEntry to enter the log as follows: ' Create the source, if it does not already exist. If Not EventLog.SourceExists("MySource") Then...
2
by: VM | last post by:
I'm trying to dynamically display the rows in a datagrid while filling the datatable source. I'm doing it this way because we had already finished the app but this section sometimes took so long...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
1
by: CES | last post by:
All, Could someone please point me to a step by step resource on setting up a ..net Web Application on IIS. I'm having a problem setting up IIS to except a new Web Application. I'm deploying...
1
by: cade | last post by:
Does anyone know an article or how to setup a project so that more than one person can work on it at a time? We have a network of computers at work and me and another guy are the programmers. We...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: angi35 | last post by:
I hope this is an easy question for someone out there. In Access 2000…I have a MainForm with a tab control (MAIN TABS) with 7 tabs. Within each tab is a SubForm. Within each SubForm is a tab...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
In the Registry at HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text the default key for Text Format is: "Format" = "CSVDelimited" I can use the following OleDB...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.