Problem getting ID from a form

R

Robin9876

On a Access 2003 form which is based on a table called Person there is
an autonumber field called PersonID on the form close I have code to
get the value from me.PersonID (or [Forms]![myForm].[PersonID]) into a
module variable. The form has record selectors.

After adding a new record, the latest id is displayed for the record
but when in the form close it returns the PersonID of the first person
in the table.

How can the current value on the screen be returned in the form close?
 
M

Marshall Barton

Robin9876 said:
On a Access 2003 form which is based on a table called Person there is
an autonumber field called PersonID on the form close I have code to
get the value from me.PersonID (or [Forms]![myForm].[PersonID]) into a
module variable. The form has record selectors.

After adding a new record, the latest id is displayed for the record
but when in the form close it returns the PersonID of the first person
in the table.

How can the current value on the screen be returned in the form close?


Sounds like you are doing something (Me.Requery??) to
reposition the form's current record.
 
Y

Yanick

On which event are you trying to retreive the data?

When you close a form the events go in the following order
Unload → Deactivate → Close

Have you tried to retreive the information you need during OnUnload or
OnDeactivate events?
 
R

Robin9876

Thanks I have now got it to work.

I moved the code to the form unload event and the form now works.

I did not have any form.requery but the form had a bound data source.


On which event are you trying to retreive the data?

When you close a form the events go in the following order
Unload $B"*(B Deactivate $B"*(B Close

Have you tried to retreive the information you need during OnUnload or
OnDeactivate events?
--
Yanick

Robin9876 said:
On a Access 2003 form which is based on a table called Person there is
an autonumber field called PersonID on the form close I have code to
get the value from me.PersonID (or [Forms]![myForm].[PersonID]) into a
module variable. The form has record selectors.
After adding a new record, the latest id is displayed for the record
but when in the form close it returns the PersonID of the first person
in the table.
How can the current value on the screen be returned in the form close?
 

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