Accessing the current record for a form...

B

Bob Quintal

Help?

I have a form that displays a database table row - I have a
command button on that form that I want to use to update an
attribute of the record that isn't displayed on the form. My
database record uses an autonumber primary key that is also
not displayed on the form. Is there some way for the code of
the command button OnClick event method to retrieve the member
of the recordset that is currently being displayed and either
update it or retrieve the value of the primary key so that I
can perform an update query against the table? (My assumption
is that the recordset that is being used to "feed" the form
contains more fields than just those being displayed on the
form.) The .CurrentRecord property appears to provide an
index into the recordset, but I don't see how to use that
attribute to update the recordset.

Can anyone provide pointers?

Thanks,
-jdc
If the field you wish to update is included in the table/query
underlying the form, you can update it very simply
me![field_name] = whatever
 
J

John Clark

Help?

I have a form that displays a database table row - I have a command
button on that form that I want to use to update an attribute of the
record that isn't displayed on the form. My database record uses an
autonumber primary key that is also not displayed on the form. Is there
some way for the code of the command button OnClick event method to
retrieve the member of the recordset that is currently being displayed
and either update it or retrieve the value of the primary key so that I
can perform an update query against the table? (My assumption is that
the recordset that is being used to "feed" the form contains more fields
than just those being displayed on the form.) The .CurrentRecord
property appears to provide an index into the recordset, but I don't see
how to use that attribute to update the recordset.

Can anyone provide pointers?

Thanks,
-jdc
 
S

SteveM

The simplest way would probably be to add the field to the form but set its
Visible property to 'No'. That way users will not see the field but you can
still reference it in code. I always have my Primary Key fields on the form
with their Visible property set to 'No'.

If you do that, it's up to you. You can either change the field's content in
code or get the Primary Key and do it with SQL.

Steve
 

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