Updating a control when I click on the another

wjoc1

Registered User.
Local time
Today, 22:44
Joined
Jul 25, 2002
Messages
117
Hi,

I have a continuous form and each line displays a record form a table. One of the fields from this table is a checkbox.

I also have another text box in the form footer which looks up a value from an underlying query using DLookup.
I use the checkbox to select certain records. When I click on the checkbox I want the text box to requery itself and display a (possibly) updated value because it now takes into account this record also.

I have tried the following:

1. In the OnClick event of the check box I have:

Me![name_of_textbox].Requery

This doesn't work, I have to click on another checkbox to just get the value of the one clicked previously. Obviously I now have one more record then I need selected. No good.....

2. Next I tried setting the focus before requerying in the OnClick:

Me![some_other_control].SetFocus
Me![name_of_textbox].Requery

Still nothing.... Same problem as highlighted in .1

3. In the OnClick event of the checkbox I have:

Me![some_other_control].SetFocus

and then in the OnLostFocus event of the checkbox :

Me![name_of _checkbox].Requery

this doesn't work either, I still have to select one more record then required before I get the correct total value in the text box.

What can I do to fix this???

Liam
 
Last edited:
Just put this in the onclick event of you checkbox:

me.refresh
 
Won't this just refresh the checkbox?
 
The problem is that the DLookup() gets its information from the table and the table is not updated immediately after you check the checkbox. The table is not updated until you move to a new record (which is why it seems to work when you click on the checkbox of another record) or when you force the record to be saved.

Try putting a save record command in the AfterUpdate event of the checkbox.

DoCmd.RunCommand acCmdSaveRecord

Just tabbing out of the checkbox control will also work if the checkbox is the last field of the record.
 

Users who are viewing this thread

Back
Top Bottom