Getting a DLookup to refresh

J

JohnB

Hi. Can anyone help me get a text fields DLookup to refresh please? This is a
bit wordy but I hope it makes sense.

I have Form1 with a Command Button and a text field on it. The command
button opens From2, which allows for certain records to be created or
ammended. The text field on Form1 has a DLookup as its control source and
selects fields from records that are created using Form2. The problem is that
when Form2 is used to update records, and then is closed, the text field on
Form1 does not show the changes. Only by closing and reopening Form1 will the
test field show the changes.

How can I get the text field DLookup to refresh when Form2 is closed?

Thanks for any help, JohnB
 
A

Allen Browne

Recalc Form1 in the Close (or AfterUpdate?) event of Form2:
Forms!Form1.Recalc
 
J

JohnB

Thanks for such a quick reply Allen. Im afraid I cant get that to work. Im
probably guilty here of oversimplifying - very often my posts are very
longwinded and I think it puts people off, so I try to give a simplistic
senario. Sorry to be awkword. Here is a more detailed explanation.

Form1 is actually called Placements Subform, Form2 is called
frmLandladyPlacements. This has a subform called frmLandladySubfom on it and
this subform has a combo called Combo3.

So when the command button on Placements Subform is clicked,
frmLandladyPlacements opens and the user updates Combo3, which is in
frmLandladySubform. Then when frmLandladyPlacements is closed, the text field
on Placements Subform should refresh. Does this change the code needed? Using
your existing code, I get the message Runtime Error 2450 - Access cant find
the form [Placements Subform] referred to ....

Again, sorry to be a pain.

Thanks, JohnB
 
A

Allen Browne

Subforms are not open in their own right.
You will therefore need to reference it through its main form.

The result will be something like this:
Forms![MyMainForm]![MySubform].Form.Recalc

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

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

JohnB said:
Thanks for such a quick reply Allen. Im afraid I cant get that to work. Im
probably guilty here of oversimplifying - very often my posts are very
longwinded and I think it puts people off, so I try to give a simplistic
senario. Sorry to be awkword. Here is a more detailed explanation.

Form1 is actually called Placements Subform, Form2 is called
frmLandladyPlacements. This has a subform called frmLandladySubfom on it
and
this subform has a combo called Combo3.

So when the command button on Placements Subform is clicked,
frmLandladyPlacements opens and the user updates Combo3, which is in
frmLandladySubform. Then when frmLandladyPlacements is closed, the text
field
on Placements Subform should refresh. Does this change the code needed?
Using
your existing code, I get the message Runtime Error 2450 - Access cant
find
the form [Placements Subform] referred to ....

Again, sorry to be a pain.

Thanks, JohnB

Allen Browne said:
Recalc Form1 in the Close (or AfterUpdate?) event of Form2:
Forms!Form1.Recalc
 
J

JohnB

Thank you Allen. That got it perfectly. Cheers, JohnB

Allen Browne said:
Subforms are not open in their own right.
You will therefore need to reference it through its main form.

The result will be something like this:
Forms![MyMainForm]![MySubform].Form.Recalc

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

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

JohnB said:
Thanks for such a quick reply Allen. Im afraid I cant get that to work. Im
probably guilty here of oversimplifying - very often my posts are very
longwinded and I think it puts people off, so I try to give a simplistic
senario. Sorry to be awkword. Here is a more detailed explanation.

Form1 is actually called Placements Subform, Form2 is called
frmLandladyPlacements. This has a subform called frmLandladySubfom on it
and
this subform has a combo called Combo3.

So when the command button on Placements Subform is clicked,
frmLandladyPlacements opens and the user updates Combo3, which is in
frmLandladySubform. Then when frmLandladyPlacements is closed, the text
field
on Placements Subform should refresh. Does this change the code needed?
Using
your existing code, I get the message Runtime Error 2450 - Access cant
find
the form [Placements Subform] referred to ....

Again, sorry to be a pain.

Thanks, JohnB

Allen Browne said:
Recalc Form1 in the Close (or AfterUpdate?) event of Form2:
Forms!Form1.Recalc


Hi. Can anyone help me get a text fields DLookup to refresh please?
This
is a
bit wordy but I hope it makes sense.

I have Form1 with a Command Button and a text field on it. The command
button opens From2, which allows for certain records to be created or
ammended. The text field on Form1 has a DLookup as its control source
and
selects fields from records that are created using Form2. The problem
is
that
when Form2 is used to update records, and then is closed, the text
field
on
Form1 does not show the changes. Only by closing and reopening Form1
will
the
test field show the changes.

How can I get the text field DLookup to refresh when Form2 is closed?

Thanks for any help, JohnB
 

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