Can I reference only detail fields?

  • Thread starter Thread starter LAS
  • Start date Start date
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
 
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/
 
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.
 
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)
 
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...
 
Back
Top