'REFRESH' Button In Access 2007 Form

C

Chris

Hello,

I am working on a database in Access 2007 partially to accomplish a
goal, but also to get familiarity with the new version of Access (I
have done quite a bit of work in the previous versions). Despite
doing a lot of Access work, I am not much of a code burner though I
can usually understand and cannibalize someone else's code. I haven't
found specifically what I am looking for in some searches and thought
someone here would be able to knock out what I am looking for in a few
minutes where it would take me a lot longer to struggle through it.

I have some unbound sub-forms allowing entry of data in look-up tables
that are then used to populate drop-down selections in the main form.
If the user needs to enter a sub-form record and use it on the current
main form record, the form need to be 'reset.' To that end, I am
looking to make a RESET button to 'refresh' the main form (for a bunch
of reasons I would prefer the button method over capture focus changes
or other triggers from the sub-form). The main form presents data in
sort order (alpha on a text field), so just closing and re-opening the
form works for a 'refresh' but usually returns the user on a different
record than the one they were working on. Ok, enough background, here
is what I am think the code needs to accomplish:

· Capture the main form record key (tblMedia.Key_Media - autonumber
numeric) for the current record in the main form (frmMedia).
· Refresh the form (close/open it?).
· Use the key stored in a variable to open the record previously being
worked on.

In my simplistic view this looks to be a straightforward way to
accomplish the refresh as a button.

Thanks in advance for your help and/or code samples.

Chris
 
B

Bill Smith

Hello,
I am working on a database in Access 2007 partially to accomplish a
goal, but also to get familiarity with the new version of Access (I
have done quite a bit of work in the previous versions). Despite
doing a lot of Access work, I am not much of a code burner though I
can usually understand and cannibalize someone else's code. I haven't
found specifically what I am looking for in some searches and thought
someone here would be able to knock out what I am looking for in a few
minutes where it would take me a lot longer to struggle through it.

I have some unbound sub-forms allowing entry of data in look-up tables
that are then used to populate drop-down selections in the main form.
If the user needs to enter a sub-form record and use it on the current
main form record, the form need to be 'reset.' To that end, I am
looking to make a RESET button to 'refresh' the main form (for a bunch
of reasons I would prefer the button method over capture focus changes
or other triggers from the sub-form). The main form presents data in
sort order (alpha on a text field), so just closing and re-opening the
form works for a 'refresh' but usually returns the user on a different
record than the one they were working on. Ok, enough background, here
is what I am think the code needs to accomplish:

· Capture the main form record key (tblMedia.Key_Media - autonumber
numeric) for the current record in the main form (frmMedia).
· Refresh the form (close/open it?).
· Use the key stored in a variable to open the record previously being
worked on.

In my simplistic view this looks to be a straightforward way to
accomplish the refresh as a button.

Thanks in advance for your help and/or code samples.

Chris


I'm a noob to '07 myself. I use Shift + F9 to refresh a form for the same
reasons you mentioned above. Maybe you could code a button control onClick
event with that.
 
C

Chris

use Shift + F9 to refresh a form for the same reasons you mentioned
above. Maybe you could code a button control onClick event with that.

Hi,

Thanks for the prompt response. Unfortunately, Shift+F9 and F5 both
reset the form but returns to the first record. It can become pretty
ungainly to have to dig through the records to find the one previously
being worked on as it rarely sorts to be the first or last record.

Thanks for the info though,

Chris
 
B

Bill Smith

Chris said:
Hi,

Thanks for the prompt response. Unfortunately, Shift+F9 and F5 both
reset the form but returns to the first record. It can become pretty
ungainly to have to dig through the records to find the one previously
being worked on as it rarely sorts to be the first or last record.

Thanks for the info though,

Chris

Sorry about that. I haven't used that control since I imported my old
databases into '07 and I see I'm in the same boat you are. In '03, it
updated the form and stayed on the same record. I'll let you know if I find
anything.
 
C

Chris

Sorry about that. I haven't used that control since I imported my old
databases into '07 and I see I'm in the same boat you are. In '03, it
updated the form and stayed on the same record. I'll let you know if I find
anything.

Sounds good - I will post anything I find here as well.

Chris
 
C

Chris

Sounds good - I will post anything I find here as well.

No sooner did I send this, than I happened across the function and it
is REALLY easy. There are two ways:

1) Create a macro using the ACTION: RunCommand with the ARGUMENT:
Refresh and assign it to a button or to a change of focus event
(OnExit, etc.)

OR

2) You can create a new button using the button tool (DESIGN Tab,
Button), then choose FORM OPERATIONS in the Categories and REFRESH
FORM DATA for the Actions.

Both of these methods allowed me to have a REFRESH button that refresh
the contents of the current record in my form without resetting the
record being shown.

Hope this helps out,

Chris
 
B

Bill Smith

Chris said:
No sooner did I send this, than I happened across the function and it
is REALLY easy. There are two ways:

1) Create a macro using the ACTION: RunCommand with the ARGUMENT:
Refresh and assign it to a button or to a change of focus event
(OnExit, etc.)

OR

2) You can create a new button using the button tool (DESIGN Tab,
Button), then choose FORM OPERATIONS in the Categories and REFRESH
FORM DATA for the Actions.

Both of these methods allowed me to have a REFRESH button that refresh
the contents of the current record in my form without resetting the
record being shown.

Hope this helps out,

Chris

Worked great, Chris. Thanks!
 

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