Form refresh

D

Dave Elliott

How can I after and or on the current event make the main form TimeCards
refresh itself so it will show the latest data after the sub-form value of
the control [Text95] changes?
Thanks,

Dave


If Forms!TimeCards![Time and Hours].Form![Text95].Value < 2 Then
Rate = [Text430] * 2
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
If Forms!TimeCards![Time and Hours].Form![Text95].Value >= 2 Then
Rate = [Text430]
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
 
A

Albert D.Kallal

it is not clear "what" in the main form needs to update, or "will" update
here?

if you are talking about some control, or value that shows a total of the
child record from the sub-form, then you should not need any code at all in
the main form. Is this contorl based on a dsum, or how is the controll
filled?

For any totals, you can just put a sum(fieldname) in the sub-forms
footer..and it will generate totals for you.

To force a update after the control text95 changes (is this a bound, or
un-bound control??)>

I would simply force a disk write of the child record. I don't think you
need any code in the forms on current. I would simply place the following
code in the text95 after update event.

me.Refresh

The above is all you should need. The above forces the current record to be
saved...
 
D

Dave Elliott

ok, the control (Rate) on the main form (TimeCards) needs to refresh itself
so it will show the correct value.
Also, now the text boxes (unbound) are also on the main form, but get there
value from the sub-form Time and Hours
So if text425 value is less than 2 then rate should equal text430 *2
else if text425 "" """ is greater than or equal to 2 , then rate equals
text430
the problem i am having is that when the value of text425 changes, (when
the sub-form Time and Hours) text box (Text95) changes then the code does
not run so as to correct the value of (Rate) when the value of text425 is
changed.
Text425 equals the sub-form Time and Hours text box Text95
Rate shows the rate which a customer is charged, i.e. 37.50 for a man hour
tried the below code to refresh , but with no success.
If i close the form (TimeCards) main form and then re-open, it does not show
the correct value in the control Rate even if I change the
value of Text425 ????

If [Text425].Value < 2 Then
Rate = [Text430] * 2
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
'Forms!TimeCards![Rate].Requery
If [Text425].Value >= 2 Then
Rate = [Text430]
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
 

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