Defining objects within a cell range  
Author Message
beckd2





PostPosted: Visual Basic for Applications (VBA), Defining objects within a cell range Top

Hey, 
   I've been working on writing a code where the user inputs different names into a worksheet, then the code selects these files and defines it:



Sheets("Variable Output Order").Select
FieldStr1 = [A2:A21]

 


Then, I use that defined object to use in a recordset:


Set rs1 = db.OpenRecordset("SELECT " & FieldStr1 _
        & " FROM R00" & TestNumber & "DATA " _
        & "ORDER BY RECORD_NUMBER")

 


Also,the TestNumber is defined also, but that doesn't seem to be the problem. Any thoughts


Microsoft ISV Community Center Forums2  
 
 
Shiva Manjunath





PostPosted: Visual Basic for Applications (VBA), Defining objects within a cell range Top

Hi,

Can you explain your problem more clearly


 
 
ADG





PostPosted: Visual Basic for Applications (VBA), Defining objects within a cell range Top

Hi

FieldStr1 will return an array of type variant (unless you have defined it otherwise), I guess you are wanting to build a string containing field names separated by commas. If you have your field names in a2:A21 you need to loop through these cells and build your string that way.