Can't get a subform to requery/refresh

  • Thread starter Slez via AccessMonster.com
  • Start date
S

Slez via AccessMonster.com

I have a multi select list box, lstCRSelect, that exists on a subform,
CtlEstimateSelectorCR (please note that is the subform control name...the
actual form being used is frmEstimateSelectorCR), of the main form, which is
frmMainScreen. I'm trying to requery the records in lstCRSelect so that it
always remains current. I have done so in a very similar application based
on help from this forum, but I can't seem to get it to work this time around.

I have the following code in the On Current event of frmMainScreen:

Private Sub Form_Current()
Forms!frmMainScreen!CtlEstimateSelectorCR.Form!lstCRSelect.Requery
End Sub

The previous application I mentioned had one additional nested form which was
lidted in the code, so it seems to me the code listed here should be right.
I also have the Master/Child fields listed properly...at least I think I do.
Does anyone have any ideas on why this might not be working?
Any feedback is appreciated!
Slez
 
M

Marshall Barton

Slez said:
I have a multi select list box, lstCRSelect, that exists on a subform,
CtlEstimateSelectorCR (please note that is the subform control name...the
actual form being used is frmEstimateSelectorCR), of the main form, which is
frmMainScreen. I'm trying to requery the records in lstCRSelect so that it
always remains current. I have done so in a very similar application based
on help from this forum, but I can't seem to get it to work this time around.

I have the following code in the On Current event of frmMainScreen:

Private Sub Form_Current()
Forms!frmMainScreen!CtlEstimateSelectorCR.Form!lstCRSelect.Requery
End Sub

The previous application I mentioned had one additional nested form which was
lidted in the code, so it seems to me the code listed here should be right.
I also have the Master/Child fields listed properly...at least I think I do.
Does anyone have any ideas on why this might not be working?


That looks correct to me. What makes you think it's not
working?

If you are trying to add a record to the main form and
display it in the list box, make sure the new record has
been saved before doing the Requery. Depending on what all
is going on in your main form, this could be as simple as:
If Me.Dirty Then Me.Dirty = False
 
S

Slez via AccessMonster.com

I can see it isn't working because when I add/delete records to a different
subform, they don't show up in lstCRSelect. In the previous application I
mentioned, as soon as you make an update, add, or delete a record, it is
immediatly refreshed.

Where would I place the code you recommended?

Thanks again!
Slez

Marshall said:
I have a multi select list box, lstCRSelect, that exists on a subform,
CtlEstimateSelectorCR (please note that is the subform control name...the
[quoted text clipped - 13 lines]
I also have the Master/Child fields listed properly...at least I think I do.
Does anyone have any ideas on why this might not be working?

That looks correct to me. What makes you think it's not
working?

If you are trying to add a record to the main form and
display it in the list box, make sure the new record has
been saved before doing the Requery. Depending on what all
is going on in your main form, this could be as simple as:
If Me.Dirty Then Me.Dirty = False
 
M

Marshall Barton

If you are not trying to add a new record in the same form,
you don't need the code I posted.

If you are operating in a different form then your requery
line should be in the other form's AfterUpdate event.
--
Marsh
MVP [MS Access]

I can see it isn't working because when I add/delete records to a different
subform, they don't show up in lstCRSelect. In the previous application I
mentioned, as soon as you make an update, add, or delete a record, it is
immediatly refreshed.

Where would I place the code you recommended?


Marshall said:
I have a multi select list box, lstCRSelect, that exists on a subform,
CtlEstimateSelectorCR (please note that is the subform control name...the
[quoted text clipped - 13 lines]
I also have the Master/Child fields listed properly...at least I think I do.
Does anyone have any ideas on why this might not be working?

That looks correct to me. What makes you think it's not
working?

If you are trying to add a record to the main form and
display it in the list box, make sure the new record has
been saved before doing the Requery. Depending on what all
is going on in your main form, this could be as simple as:
If Me.Dirty Then Me.Dirty = False
 

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