Form Refresh/Requery

  • Thread starter Branden Johnson
  • Start date
B

Branden Johnson

Using Microsoft Access 2002 (10.2627.2625)
Windows XP Pro SP1

I am fighting with a form refresh/requery issue, I think; i am not sure
exactly what I am missing. I have a form, FORM_A with a subform, SUBFORM_A.
After creating and modifying the layout of the form and its subform, I
realized I had to be able to add new records.

My problem is this: I can start entering data into the fields on FORM_A and
a new record is created. SUBFORM_A's fields are from another table linked by
a Primary Key/Foreign Key relationship. The subform does not display any
information, naturally. In my main form, I do not have any controls tied to
setting the foreign key in my table to link back to the subform's table.

My Solution:
I created a combobox on the subform and shrunk it down so that only the
button was visible. I have the combobox displaying a list of the field
values (including the primary key - hidden) and storing the information for
later use. I wrote an OnChange event for the combobox that manually adds a
new record into FORM_A's table containing only the ID field needed to link
back to SUBFORM_A's table. This was supposed to show the SUBFORM_A
information with no data in FORM_A's fields. Then I could start filling out
FORM_A.

The Problem:
When the code is done processing and control is sent back to my form, the
record does not show up. If I set focus to FORM_A and press SHIFT+F9 the
record shows up and I am good to go. I do not want to press SHIFT+F9 - so I
tried writing the code to do this for me using a FORM.SetFocus on FORM_A
(which works) and then I have tried to Refresh, Requery, SendKeys... I have
also programatically closed and reopened the form with no luck.

I can not get this to work without either closing the form manually and
reopening it, or setting focus to FORM_A and pressing SHIFT+F9.

I hope this makes sense. Thank you, in advance for any help.

Branden Johnson
BMJ Computing
 

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