Get a value from the form's current record

G

Guest

I need to get a value from a field in the current record of the table
displayed on my form.

I have a button that writes the value of a field in the form's current
record to another table; I just need to be able to get that value and can't
figure out how to do it. Is it a property of the form? Can I open the
recordset for the table and get a property for it's current record? Any other
ideas?

Thanks in advance! You folks are great!

Don
 
D

Dan Artuso

Hi,
Values on forms are displayed in controls that are bound to fields in tables.
You can get the current value in any control on your form
simply by using this syntax:
Me.yourControl

You of course have to put this value somewhere and you've not made it
clear where you want to put it but you can test this out by placing a command
button on your form and in the click event put:

MsgBox Me.yourControl

Of course you have to substitute the real name of the control.
 
G

Guest

Dan--

Thanks for your fast reply!

The field whose value I want is not bound to a control on my form; it is the
primary key field (with an autonumbered index number) for the form's current
record. I could, I suppose, put a control on my form for that field, but that
seems pretty desperate!

I am able to get the value for the form's current record with the
CurrentRecord property, but I haven't figured out how to use that value to
get the value of a field in that record.

Any ideas?

Don
 
D

Dirk Goldgar

Don Starnes said:
I need to get a value from a field in the current record of the table
displayed on my form.

I have a button that writes the value of a field in the form's current
record to another table; I just need to be able to get that value and
can't figure out how to do it. Is it a property of the form? Can I
open the recordset for the table and get a property for it's current
record? Any other ideas?

Thanks in advance! You folks are great!

Don

All the fields in a bound form's recordsource are available as
properties of the form, if their names don't confllict with built-in
properties. So if your form's recordsource includes a field named
"MyField", then you can get the value of that field even if no control
is bound to it, just referring to

Me.MyField
 

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