Problem getting ID from a form

  • Thread starter Thread starter Robin9876
  • Start date Start date
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?
 
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.
 
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?
 
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?
 
Back
Top