label control won't update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a main form with a tab strip control containing 3 tabbed pages.
Each tabbed page contains a subform. Each tabbed page contains label controls.

In the footer section of each subform are text box controls with sum
functions used to sum the values in particular rows of the data sheet.

In the change event of the tabcontrol which is on the main form I have code
like this:

With Me.SubFormChild1.Form.RecordsetClone
If .RecordCount > 0 Then
Me.lblamount.Caption =
Format(Me.SubFormChild1.Form.txtamounttotal.Value, "#,##.00")
End If
End With

the recordsetclone is used to determine if there are records because if
there are
none and I try to put the totaled value into the caption property it will
error.

This works fine when I step through the code in debug mode.
If I turn off the break point and let it run without stopping the labels do
not
get populated they are empty and my default value of 0 (zero) is wiped out.

Now when I exist the debugged code I have to goto the window drop down in
Access and choose my main form again to get it to be seen. This likely fires
some sort of event that refreshes the form or something and lets the values
display.

I played around with refreshing the form wiht .refresh but does'nt work.

I'm confused.

Chris
 
Chris said:
I have a main form with a tab strip control containing 3 tabbed pages.
Each tabbed page contains a subform. Each tabbed page contains label controls.

In the footer section of each subform are text box controls with sum
functions used to sum the values in particular rows of the data sheet.

In the change event of the tabcontrol which is on the main form I have code
like this:

With Me.SubFormChild1.Form.RecordsetClone
If .RecordCount > 0 Then
Me.lblamount.Caption =
Format(Me.SubFormChild1.Form.txtamounttotal.Value, "#,##.00")
End If
End With

the recordsetclone is used to determine if there are records because if
there are
none and I try to put the totaled value into the caption property it will
error.

This works fine when I step through the code in debug mode.
If I turn off the break point and let it run without stopping the labels do
not
get populated they are empty and my default value of 0 (zero) is wiped out.

Now when I exist the debugged code I have to goto the window drop down in
Access and choose my main form again to get it to be seen. This likely fires
some sort of event that refreshes the form or something and lets the values
display.


Try using the Repaint method at the end of your procedure.

If that's insufficient, then try adding a DoEvents statement
before you retrieve the value from the sum control.

If neither or both of those don't work, then the timing
issue (code runs before the Sum is calculated) is too severe
and you won't be able to use code to get this effect. Try
changing the label to a text box that refers to the Sum text
box.
 
thanks Marshall but it still does'nt work.

I tried everything you suggested and then some, there is still a timing issue
I believe. Even on just setting the control source of a textbox to the value
of the text box on the subform, it does not work.

This is frustrating and a very simple request of the capabilities of Access
2000
to perform but still no go.

I put in a do loop with 1000 DoEvents and still would'nt update the textbox.

Do you have any other suggestions.
 
Did you try removing the Change event code and changing the
label on the main form to a text box with the expression:
Format(Me.SubFormChild1.Form.txtamounttotal.Value,
"#,##.00") Event then you will probaly need to use one or
two DoEvents and/or a Repaint.

If you can live with it, moving that text box to the subform
footer may simplify the situation a little.

Beyond that, I don't think you're going to be able to
resolve all the timing issues involved here. The subform
requery caused by changing the filtering in the subform is
one processing thread, displaying the updated form data is
another, while code execution is yet a third. That's a lot
of tasks to try to coordinate, especially when you are not
writing the code for most of it.
 
I did remove the label and put in a textbox instead and then
put txtamounttotal value right into the textbox from there using


That did not work.

I do need change event code because the 2nd tab is a drill down from the
first tab.
On the first tab you set focus to a row on the subform. When you click on
the 2nd tab you load the 2nd tab subform based on the current record of the
1st tab.
I need the change event because I send parameters (gathered from 1st tab
current record) to a stored procedure on the SQL Server.

Since you did mention using repaint and doevents again, I believe you agree
with my need to continue to use VBA.


Marshall Barton said:
Did you try removing the Change event code and changing the
label on the main form to a text box with the expression:
Format(Me.SubFormChild1.Form.txtamounttotal.Value,
"#,##.00") Event then you will probaly need to use one or
two DoEvents and/or a Repaint.

If you can live with it, moving that text box to the subform
footer may simplify the situation a little.

Beyond that, I don't think you're going to be able to
resolve all the timing issues involved here. The subform
requery caused by changing the filtering in the subform is
one processing thread, displaying the updated form data is
another, while code execution is yet a third. That's a lot
of tasks to try to coordinate, especially when you are not
writing the code for most of it.
--
Marsh
MVP [MS Access]

thanks Marshall but it still does'nt work.

I tried everything you suggested and then some, there is still a timing issue
I believe. Even on just setting the control source of a textbox to the value
of the text box on the subform, it does not work.

This is frustrating and a very simple request of the capabilities of Access
2000
to perform but still no go.

I put in a do loop with 1000 DoEvents and still would'nt update the textbox.

Do you have any other suggestions.
 
I found a solution that is pretty annoying to have to resort to. I ashamed of
myself
for having to resort to this solution.

On the main form I set the timer interval to 3 seconds and on the ontimer
event
put the code in for filling in the textboxes on the mainform.

This appears to be my solution for now.

Thanks for the advice Marshall.

Marshall Barton said:
Did you try removing the Change event code and changing the
label on the main form to a text box with the expression:
Format(Me.SubFormChild1.Form.txtamounttotal.Value,
"#,##.00") Event then you will probaly need to use one or
two DoEvents and/or a Repaint.

If you can live with it, moving that text box to the subform
footer may simplify the situation a little.

Beyond that, I don't think you're going to be able to
resolve all the timing issues involved here. The subform
requery caused by changing the filtering in the subform is
one processing thread, displaying the updated form data is
another, while code execution is yet a third. That's a lot
of tasks to try to coordinate, especially when you are not
writing the code for most of it.
--
Marsh
MVP [MS Access]

thanks Marshall but it still does'nt work.

I tried everything you suggested and then some, there is still a timing issue
I believe. Even on just setting the control source of a textbox to the value
of the text box on the subform, it does not work.

This is frustrating and a very simple request of the capabilities of Access
2000
to perform but still no go.

I put in a do loop with 1000 DoEvents and still would'nt update the textbox.

Do you have any other suggestions.
 
Sorry, I didn't mean to imply that you can't have any code
in the tab control's Change event. What I was trying to say
is that the event procedure can not retrieve the value of
the subform's Sum text box.

Again, the issue is tied up in the timing of the (at least)
three tasks that Access is using to retrieve data,
calculate expression values, paint the screen and execute
code. If you can remove the dependency on the code
execution task, which runs at the highest priority, from the
problem, you stand a much better chance of achieving an
acceptable result.

Your post didn't contain what you used to get the subform
value into the main form text box, so I can't evaluate
whatever you used. Also, the only clue you provided as to
the result was "That did not work.", which is not especially
informative when trying to deduce a solution from what is
essentially a trial and error exercise.
--
Marsh
MVP [MS Access]


I did remove the label and put in a textbox instead and then
put txtamounttotal value right into the textbox from there using

That did not work.

I do need change event code because the 2nd tab is a drill down from the
first tab.
On the first tab you set focus to a row on the subform. When you click on
the 2nd tab you load the 2nd tab subform based on the current record of the
1st tab.
I need the change event because I send parameters (gathered from 1st tab
current record) to a stored procedure on the SQL Server.

Since you did mention using repaint and doevents again, I believe you agree
with my need to continue to use VBA.


Marshall Barton said:
Did you try removing the Change event code and changing the
label on the main form to a text box with the expression:
Format(Me.SubFormChild1.Form.txtamounttotal.Value,
"#,##.00") Event then you will probaly need to use one or
two DoEvents and/or a Repaint.

If you can live with it, moving that text box to the subform
footer may simplify the situation a little.

Beyond that, I don't think you're going to be able to
resolve all the timing issues involved here. The subform
requery caused by changing the filtering in the subform is
one processing thread, displaying the updated form data is
another, while code execution is yet a third. That's a lot
of tasks to try to coordinate, especially when you are not
writing the code for most of it.
--
Marsh
MVP [MS Access]

thanks Marshall but it still does'nt work.

I tried everything you suggested and then some, there is still a timing issue
I believe. Even on just setting the control source of a textbox to the value
of the text box on the subform, it does not work.

This is frustrating and a very simple request of the capabilities of Access
2000
to perform but still no go.

I put in a do loop with 1000 DoEvents and still would'nt update the textbox.

Do you have any other suggestions.


Chris wrote:
I have a main form with a tab strip control containing 3 tabbed pages.
Each tabbed page contains a subform. Each tabbed page contains label controls.

In the footer section of each subform are text box controls with sum
functions used to sum the values in particular rows of the data sheet.

In the change event of the tabcontrol which is on the main form I have code
like this:

With Me.SubFormChild1.Form.RecordsetClone
If .RecordCount > 0 Then
Me.lblamount.Caption =
Format(Me.SubFormChild1.Form.txtamounttotal.Value, "#,##.00")
End If
End With

the recordsetclone is used to determine if there are records because if
there are
none and I try to put the totaled value into the caption property it will
error.

This works fine when I step through the code in debug mode.
If I turn off the break point and let it run without stopping the labels do
not
get populated they are empty and my default value of 0 (zero) is wiped out.

Now when I exist the debugged code I have to goto the window drop down in
Access and choose my main form again to get it to be seen. This likely fires
some sort of event that refreshes the form or something and lets the values
display.


:
Try using the Repaint method at the end of your procedure.

If that's insufficient, then try adding a DoEvents statement
before you retrieve the value from the sum control.

If neither or both of those don't work, then the timing
issue (code runs before the Sum is calculated) is too severe
and you won't be able to use code to get this effect. Try
changing the label to a text box that refers to the Sum text
box.
 
Yeah, I hate resorting to a timer event too, but I guess
that's one way to divorce the code retrieving the Sum value
from the the other tasks.

What about just displaying the Sum text box value in the
subform so the main form problem becomes moot?
--
Marsh
MVP [MS Access]

I found a solution that is pretty annoying to have to resort to. I ashamed of
myself for having to resort to this solution.

On the main form I set the timer interval to 3 seconds and on the ontimer
event
put the code in for filling in the textboxes on the mainform.


Marshall Barton said:
Did you try removing the Change event code and changing the
label on the main form to a text box with the expression:
Format(Me.SubFormChild1.Form.txtamounttotal.Value,
"#,##.00") Event then you will probaly need to use one or
two DoEvents and/or a Repaint.

If you can live with it, moving that text box to the subform
footer may simplify the situation a little.

Beyond that, I don't think you're going to be able to
resolve all the timing issues involved here. The subform
requery caused by changing the filtering in the subform is
one processing thread, displaying the updated form data is
another, while code execution is yet a third. That's a lot
of tasks to try to coordinate, especially when you are not
writing the code for most of it.
--
Marsh
MVP [MS Access]

thanks Marshall but it still does'nt work.

I tried everything you suggested and then some, there is still a timing issue
I believe. Even on just setting the control source of a textbox to the value
of the text box on the subform, it does not work.

This is frustrating and a very simple request of the capabilities of Access
2000
to perform but still no go.

I put in a do loop with 1000 DoEvents and still would'nt update the textbox.

Do you have any other suggestions.


Chris wrote:
I have a main form with a tab strip control containing 3 tabbed pages.
Each tabbed page contains a subform. Each tabbed page contains label controls.

In the footer section of each subform are text box controls with sum
functions used to sum the values in particular rows of the data sheet.

In the change event of the tabcontrol which is on the main form I have code
like this:

With Me.SubFormChild1.Form.RecordsetClone
If .RecordCount > 0 Then
Me.lblamount.Caption =
Format(Me.SubFormChild1.Form.txtamounttotal.Value, "#,##.00")
End If
End With

the recordsetclone is used to determine if there are records because if
there are
none and I try to put the totaled value into the caption property it will
error.

This works fine when I step through the code in debug mode.
If I turn off the break point and let it run without stopping the labels do
not
get populated they are empty and my default value of 0 (zero) is wiped out.

Now when I exist the debugged code I have to goto the window drop down in
Access and choose my main form again to get it to be seen. This likely fires
some sort of event that refreshes the form or something and lets the values
display.


:
Try using the Repaint method at the end of your procedure.

If that's insufficient, then try adding a DoEvents statement
before you retrieve the value from the sum control.

If neither or both of those don't work, then the timing
issue (code runs before the Sum is calculated) is too severe
and you won't be able to use code to get this effect. Try
changing the label to a text box that refers to the Sum text
box.
 
Back
Top