View Single Post
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Frank A Frugone Frank A Frugone is offline
external usenet poster
 
Posts: 2
Default When I change the querystring to use a different table, thefieldnames don't update

I'm using an OLEDB connection to an excel workbook. The workbook has
two spreadsheets with data. When I use the datasource.querystring
property to change the name of the spreadsheet (table) I'm using, the
fieldnames remain what they were for the first table. How can I get
the fieldnames to update to those of the second table?

I don't have any idea how the process of gathering the field names
works. I put the field names I want in the first row of the table and
it always picks up on the for table I specify in the opendatasource
sql statement.

I suddenly have an idea for a workaround. What if I use a sql
statement in the opendatasource statement like: "SELECT * table1,
table2", and then change the query string to "SELECT * table1
WHERE ..." and after I gathered all the info from table1, change the
querystring to "SELECT * table2 WHERE ..."? Could work. Only problem
is, I was using both SQLStatement, and SQLStatement1 in the
opendatasource statement because my queries can be long and the
querystring property can only be used up to something like 255
characters. Any ideas about that?

Thanks.