Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help once again with VB code 1

Status
Not open for further replies.

kah0563

Programmer
Feb 7, 2005
6
US
I am writing a SQL statement in VB to establish connection with Access dbase. Connection works fine. One of the tables in the dbase will have variable fields (another words, may have 10 fields in dbase, and 15 in another). Therefore, i want to concatenate part of the field name with a variable when extracting this information from the dbase. Example,

If mrsHNC.RecordCount > 0 Then
mrsHNC.MoveFirst
For counter = 4 To mrsHNC.RecordCount + 3
With mrsHNC
c = 2
Range("a" & counter) = !acct_id
Do Until c = Range("MATINCOUNT")
Cells(counter, c) = !mat & c - 1
c = c + 1
Loop

The Do Until Loop is the part I am having trouble with. It doesn't like the !mat & c -1 concatenation. Is there a way to concatenate part of a field name with a variable?? I've tried [] around partial field name "mat", but can't seem to find a combination that works. Not sure if this is feasible or not? Thanks for any help
 
Cells(counter, c) = mrsHNC("mat" & (c - 1))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top