Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't refresh table

Status
Not open for further replies.

sstasiak

MIS
Feb 8, 2007
21
0
0
US
Hi

I have a form frmOncRegMain that contains a combo box for a list of names. Next to this box is a button to add a new name to the list. The button opens a NameEntry form that accepts text.

In this NameEntry form I created a save button that is supposed to save the name to tblNames, close the form, then refresh the table so the new name is reflected in the combo box.

So I click "Add new" button which runs a macro to "OpenForm" NameEntry.

NameEntry opens, I type a name in the text box and click the "Save" button. The macro controlling this button says:

Action
"Close" Form, NameEntry,Prompt
"RunCommand" Refresh

This was working perfectly and all of a sudden when I entered a new name and tried to save it, I got an error saying that "The command or action "Refresh" isn't available.

I didn't make any changes to the table, form, or macro and it just started happening. Any ideas?

 
It sound like the focus is not returning to your main form, so refresh is not available. How do you feel about a little code?
 
Not to good with the code, but I got it working.

I just added a macro so the main form refreshes when the combobox is clicked.

Thanks anyway
 
In my case, I sometimes need to select a name from a list, and sometimes need to add a new one right from the form. When I add a name, it doesn't automatically populate the combobox, so I need to select it. But the change in the table doesn't reflect in the list until the form is refreshed.

I just set a macro on the combo box to refresh when the dropdown arrow is clicked. That way the form refreshes right when you hit the arrow
 
Hi,
One line of code would fix this. Instead of refreshing the form, you need to refresh the combo box. I had the same problem until someone from this forum gave me the solution.
I did it using vb code. If you need the code, let me know.
Like I said, it is one line. Very simple.



Remember when... everything worked and there was a reason for it?
 
gshen

I'd like to see that code. Does this site have a private message feature?
 
It is quite simple to requery a combobox in code.

If you want to requery from a form other than the current form, you would say:
[tt]Forms![Form Name]![Combo Name].Requery[/tt]

If you wish to requery from the current form, you can shorten this:
[tt]Me![Combo Name].Requery[/tt]

If you wish to requery on a subform of the current form, you would say:
[tt]Me![Subform Control Name].Form![Combo Name].Requery[/tt]

The only other problem is to choose the event in which to requery.
 
Thanks Remou for responding. I got tied up on a problem.

sstasiak,
The code Remou put in is right on the money and it works like a charm.

Remember when... everything worked and there was a reason for it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top