dynamic field assignment in recordset edit

G

Guest

Hi,

I would like to put a variable in place of the value F2 (F2 being the field
name)
This way I can control which field is being edited by way of a variable.

example: sField

Do While Not rst.EOF

With rst
.Edit
'TODO: add dynamic field addressing using sfieldname variable
!F2 = String(fieldsize - Len(CStr(countstart)), "0") &
CStr(countstart)
rst.Update
rst.MoveNext
End With

loop

Could someone please show me how to do this.

Thanks

Chris
 
A

Allen Browne

Instead of:
rs!F2
use:
rs(sField)
where sField is the string variable containing "F2".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top