B
Bob Quintal
=?Utf-8?B?QWNjZXNzTWFu?= <[email protected]>
wrote in
subform record is created?
And do you mean that it should start at 1 for each new parent
record that is created?
if no is the answer to either of those questions, we'll need a
lot more detail on what you are trying to accomplish.
If you've answered yes to both my questions, just add this to
the On Current event of the subform
If me.newRecord then
me.hiddenfield = nz(dMax("hiddenfield","subformtablename",
"mainkeyname = " & parent.mainkeyname & ")"
end if
substitute real names for hiddenfield, subformtablename and
mainkeyname.
Also if mainkeyname refers to a text field, not a number, then
the last portion of the query (after the = sign should have
extra quotes: = """ & parent.mainkeyname & """)"
wrote in
you say as each subform record is updated. Do you mean as eachI have a subform that has a hidden field that is part of the
key, but which is irrelevant for this particular form. I need
to apply a unique value to each subform record to avoid key
violations, and I would like this to happen automatically as
each subform record is updated. I'm new to VB, and I think
I know how to update the field value, but it's not obvious to
me what to use as a source for the update value. Ideally, it
should be a sequential autonumber that starts at 1 each time
the subform is opened. Any ideas? Thanks!
subform record is created?
And do you mean that it should start at 1 for each new parent
record that is created?
if no is the answer to either of those questions, we'll need a
lot more detail on what you are trying to accomplish.
If you've answered yes to both my questions, just add this to
the On Current event of the subform
If me.newRecord then
me.hiddenfield = nz(dMax("hiddenfield","subformtablename",
"mainkeyname = " & parent.mainkeyname & ")"
end if
substitute real names for hiddenfield, subformtablename and
mainkeyname.
Also if mainkeyname refers to a text field, not a number, then
the last portion of the query (after the = sign should have
extra quotes: = """ & parent.mainkeyname & """)"