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
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