Can I reference only detail fields?

L

LAS

I have a loop (see below) that references all the fields in a form. Is it
possible to restrict this to the detail section of the form?

For Each fld In frmSomeForm.Fields
rstSomeRst(fld.Name) = frmSomeForm(fld.Name)
Next fld

tia
las
 
T

Tony Toews

I have a loop (see below) that references all the fields in a form. Is it
possible to restrict this to the detail section of the form?

For Each fld In frmSomeForm.Fields
rstSomeRst(fld.Name) = frmSomeForm(fld.Name)
Next fld

One means might be to use the controls Tag Property and the Instr
function to find those controls. I prefer Instr rather than just
using an = should you decide to put multiple values in the Tag
property.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
L

LAS

OK, thanks.

BTW - I see now, for this particular loop, that my question is academic,
because I should be using the rstSomeRst.Fields to drive the loop.
 
D

David-W-Fenton

I have a loop (see below) that references all the fields in a
form. Is it possible to restrict this to the detail section of
the form?

For Each fld In frmSomeForm.Fields
rstSomeRst(fld.Name) = frmSomeForm(fld.Name)
Next fld

I know you don't need the answer any longer, but you can do this:

For Each ctl In frmSomeForm.Section(acDetail).Controls
...
Next ctl

(the named constants for sections are actually rather hard to find
they are:

acDetail
acFooter
acGroupLevel1Footer
acGroupLevel1Header
acGroupLevel2Footer
acGroupLevel2Header
acHeader
acPageFooter
acPageHeader

These can be found by opening the Object Browser in the VBE and
searching for the acSection enum definition)
 
T

Tony Toews

D

David-W-Fenton

I knew there was an answer but I didn't quite feel like going
through the help and figuring i out.

I could have cited my usual spiel on setting up custom collections,
and would have done so had it been a live issue...
 

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