Save record

  • Thread starter Thread starter LMB
  • Start date Start date
L

LMB

Hi,

I have a cmd button on a form that opens up a look up table so the user can add a name to the table. When I added the button, I used a macro and selected Open Object then clicked on the table to open to the add record view. It works but when I type in the new name and close out of the table, the name is not available in the lookup list unless I click on the next record in the table. How can I get the record to update when I close the table?

Thanks,
Linda
 
After adding the data to the table, requery the lookup list, e.g.:
Me.MyCombo.Requery

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

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


I have a cmd button on a form that opens up a look up table so the user can
add a name to the table. When I added the button, I used a macro and
selected Open Object then clicked on the table to open to the add record
view. It works but when I type in the new name and close out of the table,
the name is not available in the lookup list unless I click on the next
record in the table. How can I get the record to update when I close the
table?

Thanks,
Linda
 
Sorry Allen, Could you tell me where to enter "Me.MyCombo.Requery" I assume I would insert the name of my combobox in the place of MyCombo?


Thanks,
Linda
After adding the data to the table, requery the lookup list, e.g.:
Me.MyCombo.Requery

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

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


I have a cmd button on a form that opens up a look up table so the user can
add a name to the table. When I added the button, I used a macro and
selected Open Object then clicked on the table to open to the add record
view. It works but when I type in the new name and close out of the table,
the name is not available in the lookup list unless I click on the next
record in the table. How can I get the record to update when I close the
table?

Thanks,
Linda
 
Hi Linda

Not exactly clear here, but if you need to run this code whenever the new
record is added to the look up table, you need to create a *form* for adding
records to the lookup table, instead of opening the table directly. The form
has an AfterUpdate event that runs whenever you add or change a record. You
can use that event to see if the other form is open, and requery its combo.

Private Sub Form_AfterUpdate()
If IsLoaded("MyOtherForm") Then
Forms("MyOtherForm).MyCombo.Requery
End If
End Sub

Yes, replace "MyCombo" with the name of your comb, and "MyOtherForm" with
the name name of your original form. Copy the IsLoaded() function from the
Northwind sample database. Or if you are using Access 2000 or later you
could replace the first line in the function with:
If CurrentProject.AllForms("MyOtherForm").IsLoaded Then

You may want to use the AfterDelConfirm event of the lookup's form as well,
so that you delete any entries in the combo if they are deleted from the
lookup table.

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

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

Sorry Allen, Could you tell me where to enter "Me.MyCombo.Requery" I
assume I would insert the name of my combobox in the place of MyCombo?


Thanks,
Linda

After adding the data to the table, requery the lookup list, e.g.:
Me.MyCombo.Requery


I have a cmd button on a form that opens up a look up table so the user
can
add a name to the table. When I added the button, I used a macro and
selected Open Object then clicked on the table to open to the add record
view. It works but when I type in the new name and close out of the
table,
the name is not available in the lookup list unless I click on the next
record in the table. How can I get the record to update when I close the
table?

Thanks,
Linda
 
Oh..I see.

Thanks,
Linda
Hi Linda

Not exactly clear here, but if you need to run this code whenever the new
record is added to the look up table, you need to create a *form* for adding
records to the lookup table, instead of opening the table directly. The form
has an AfterUpdate event that runs whenever you add or change a record. You
can use that event to see if the other form is open, and requery its combo.

Private Sub Form_AfterUpdate()
If IsLoaded("MyOtherForm") Then
Forms("MyOtherForm).MyCombo.Requery
End If
End Sub

Yes, replace "MyCombo" with the name of your comb, and "MyOtherForm" with
the name name of your original form. Copy the IsLoaded() function from the
Northwind sample database. Or if you are using Access 2000 or later you
could replace the first line in the function with:
If CurrentProject.AllForms("MyOtherForm").IsLoaded Then

You may want to use the AfterDelConfirm event of the lookup's form as well,
so that you delete any entries in the combo if they are deleted from the
lookup table.

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

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

Sorry Allen, Could you tell me where to enter "Me.MyCombo.Requery" I
assume I would insert the name of my combobox in the place of MyCombo?


Thanks,
Linda

After adding the data to the table, requery the lookup list, e.g.:
Me.MyCombo.Requery


I have a cmd button on a form that opens up a look up table so the user
can
add a name to the table. When I added the button, I used a macro and
selected Open Object then clicked on the table to open to the add record
view. It works but when I type in the new name and close out of the
table,
the name is not available in the lookup list unless I click on the next
record in the table. How can I get the record to update when I close the
table?

Thanks,
Linda
 
Back
Top