Record Fields Collection

B

Bill

I'm trying to set one of the fields in the current
record, which I assume I can do if I have the
right name for the collection. I thought it was
"Fields", but either that's wrong or how I've
used it here is wrong?????

Me.Fields("SubCat" & level "ID") = lngNewID

Where the current record contains fields of:
SubCat1ID, SubCat2ID,,,,,,,,,SubCatxID.

Bill
 
M

Marshall Barton

Bill said:
I'm trying to set one of the fields in the current
record, which I assume I can do if I have the
right name for the collection. I thought it was
"Fields", but either that's wrong or how I've
used it here is wrong?????

Me.Fields("SubCat" & level "ID") = lngNewID

Where the current record contains fields of:
SubCat1ID, SubCat2ID,,,,,,,,,SubCatxID.


If the SubCatxID things are controls on the form or fields
in the form's record source table/query:
Me("SubCat" & level & "ID") = lngNewID
or
Me.Controls("SubCat" & level & "ID") = lngNewID
 
B

Bill

Thanks, I didn't realize references to fields were
of the same syntax as those for controls. Believing
they were different, I didn't even try:
Me("SubCat" & level & "ID") = lngNewID
which I use with some regularity.
Bill
 
M

Marshall Barton

It's kind of a shortcut where both the controls and the
recordsource fields are made properties of the form. It
really blurs the distinction between controls and fields,
but it is convenient. If a field and a control have the
same name, the controls is used.

I think the formal alternative is to go through the form's
Recordset or RecordsetClone:

Since A2K
Me.Recordset.Fields( . . .
or
Me.Recordset( . . .
or, in any version
Me.RecordsetClone( . . .
 
Top