Updating Tables within Forms

G

Guest

I have a database that I use to track my recipes. I have the main table as
"Recipes" and a field in that table as "Meat Type". In order to keep things
consistent, "Meat Type" is a dropdown. I've added a button to the main form
beside the "Meat Type" box that says "Add" - I use this to add a meat if it
doesn't already exist in the dropdown. Where I run into a problem is that
when I enter the "Meat Type" form and input a new value & save/exit, I go
back to the "Recipes" form (which is what I want) but the new value doesn't
appear in the dropdown (which I need it to). I can only make it appear by
first exiting out of the "Recipes" form and then going back in. Is there a
way to refresh the "Recipes" form/table when a new "Meat Type" is added
without having to exit & reenter the form?
 
A

Allen Browne

Use the AfterUpdate event procedure of the *form* where you add new meat
types, to Requery the combo on the other form it is open.

This kind of thing:

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("Form1").IsLoaded Then
Forms("Form1")![Meat Type].Requery
End If
End Sub
 
G

Guest

Hi Allen,
Thanks for the help - but would you please explain where I add the event? Do
I need to add a button to the screen or is there somewhere on the form that I
can paste the VB (one of the properties boxes)? You've been so helpful -
thanks!
--
Thank you! - Jennifer


Allen Browne said:
Use the AfterUpdate event procedure of the *form* where you add new meat
types, to Requery the combo on the other form it is open.

This kind of thing:

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("Form1").IsLoaded Then
Forms("Form1")![Meat Type].Requery
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Jennifer Cali said:
I have a database that I use to track my recipes. I have the main table as
"Recipes" and a field in that table as "Meat Type". In order to keep
things
consistent, "Meat Type" is a dropdown. I've added a button to the main
form
beside the "Meat Type" box that says "Add" - I use this to add a meat if
it
doesn't already exist in the dropdown. Where I run into a problem is that
when I enter the "Meat Type" form and input a new value & save/exit, I go
back to the "Recipes" form (which is what I want) but the new value
doesn't
appear in the dropdown (which I need it to). I can only make it appear by
first exiting out of the "Recipes" form and then going back in. Is there a
way to refresh the "Recipes" form/table when a new "Meat Type" is added
without having to exit & reenter the form?
 
A

Allen Browne

1. Open the form where you add the meat type, in Design view.

2. Open the Properties box.

3. Make sure you are looking at the properties of the form, not those of the
text box. (The Title of the Properties box should read "Form.")

4. On the Event tab, set the AfterUpdate property to:
[Event Procedure]

5. Click the Build button (...) beside that.
Access opens the code window.

6. Add the 3 lines of code between the "Private Sub..." and "End Sub" lines.

7. Replace the 2 references to "Form1" with the actual name of your other
form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Jennifer Cali said:
Hi Allen,
Thanks for the help - but would you please explain where I add the event?
Do
I need to add a button to the screen or is there somewhere on the form
that I
can paste the VB (one of the properties boxes)? You've been so helpful -
thanks!
--
Thank you! - Jennifer


Allen Browne said:
Use the AfterUpdate event procedure of the *form* where you add new meat
types, to Requery the combo on the other form it is open.

This kind of thing:

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("Form1").IsLoaded Then
Forms("Form1")![Meat Type].Requery
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Jennifer Cali said:
I have a database that I use to track my recipes. I have the main table
as
"Recipes" and a field in that table as "Meat Type". In order to keep
things
consistent, "Meat Type" is a dropdown. I've added a button to the main
form
beside the "Meat Type" box that says "Add" - I use this to add a meat
if
it
doesn't already exist in the dropdown. Where I run into a problem is
that
when I enter the "Meat Type" form and input a new value & save/exit, I
go
back to the "Recipes" form (which is what I want) but the new value
doesn't
appear in the dropdown (which I need it to). I can only make it appear
by
first exiting out of the "Recipes" form and then going back in. Is
there a
way to refresh the "Recipes" form/table when a new "Meat Type" is added
without having to exit & reenter the form?
 

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

Similar Threads


Top