Unexplained label behavior

  • Thread starter Thread starter Dave the wave
  • Start date Start date
D

Dave the wave

I have a form with 2 subforms. The first subform displays based on an SQL
statement. The second is in the footer of the main form and is only there to
display 2 summary numbers from a separate query.

At first I used text boxes and set their values from a query. The problem
was that (even with the tab stops set to no) when the form loaded the cursor
would hide the value. So I added 2 labels to the subform, 2 lines of code to
set the labels to the text box values and figured the problem was solved.

When I open the form neither label has a value. If I make the code break and
then step through (using F8) the code the values appear as expected???? I've
thrown in some MSGBOX commands to display the values of the text boxes and
sure enough they are blank, unless I step through the code????

TABLE/FIELD:
Repacks/RepackNumber (reference number for each investigation)
Repacks/RepackTotalCases (number of cases involved.)

FORMS:
frmIReview [no record source] just a container form.

SUBFORMS:
sfrmIReview (which is working fine) no link between frmIReview and
sfrmIReview.
sfrmRepackTotals [record source = Repacks]

LABELS:
lblTotalCases=Sum([RepackTotalCases])
lblTotalInvestigations=Count([RepackNumber])

TEXT BOXES:
tbxRepackTotalCases
tbxTotalInvestigations


Here is my code:
Private Sub Form_Load()
Me.lblTotalCases.Caption = Me.tbxRepackTotalCases
Me.lblTotalInvestigations.Caption = Me.tbxTotalInvestigations
vartemp = MsgBox("Total Cases " & Me.tbxRepackTotalCases, vbOKOnly)

End Sub

I left one of the MSGBOX lines in to show how I was trying to determine what
the text box value was. If I step through the code the value is set,
otherwise the text box does not contain a value.

If anyone might suggest where the problem lies, or knows of a better
way.....I am all ears and very grateful.
 
Sounds as if there is a timing issue here...your code is running faster than
the form can load its data.

Is your code running in the main form's Load event procedure? If yes, try
moving the code for setting the values to the form's Activate event. If that
doesn't work you might try using the Current event of the subform that runs
the query.
 
Ken:
Thanks much for your response.
I've tried moving the code around but it causes other problems. Here is the
code I used:

sfrmRepackTotals.lblTotalCases.Caption =
sfrmRepackTotals.tbxRepackTotalCases
sfrmRepackTotals.lblTotalInvestigations.Caption =
sfrmRepackTotals.tbxTotalInvestigations

The error message is:
Method or data member not found.

I tried putting a delay (For i = 1 to 100000) in the open event for the
subform, but that didn't help either. However initially I defined i as an
integer and set the end value to 100,000,000 which caused an overflow error.
After the error message box was closed the values appeared as expected.

What I don't understand about the problem being timing is that this subform
is not related/linked in anyway to either the main form or the other
subform.

I decided to create a Summary Query and used the Count and Sum values to
load the label controls. DUH! Works great. (I was previously calculating the
value directly from the table.)

Review of changes for posterity:
sfrmRepackTotals [record source = qryRepacksSummary] (2 fields in query:
SumRepackTotalCases, CountRepackID)

TEXT BOXES:
tbxRepackTotalCases=SumRepackTotalCases (from qryRepacksSummary)
tbxTotalInvestigations=CountRepackID (from qryRepacksSummary)

LABELS:
lblTotalCases.caption=tbxRepackTotalCases
lblTotalInvestigations.caption=tbxTotalInvestigations

Thanks again for your help.

--
from
Dave the wave~~~~~

Ken Snell said:
Sounds as if there is a timing issue here...your code is running faster
than
the form can load its data.

Is your code running in the main form's Load event procedure? If yes, try
moving the code for setting the values to the form's Activate event. If
that
doesn't work you might try using the Current event of the subform that
runs
the query.

--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
I have a form with 2 subforms. The first subform displays based on an SQL
statement. The second is in the footer of the main form and is only there to
display 2 summary numbers from a separate query.

At first I used text boxes and set their values from a query. The problem
was that (even with the tab stops set to no) when the form loaded the cursor
would hide the value. So I added 2 labels to the subform, 2 lines of code to
set the labels to the text box values and figured the problem was solved.

When I open the form neither label has a value. If I make the code break and
then step through (using F8) the code the values appear as expected???? I've
thrown in some MSGBOX commands to display the values of the text boxes
and
sure enough they are blank, unless I step through the code????

TABLE/FIELD:
Repacks/RepackNumber (reference number for each investigation)
Repacks/RepackTotalCases (number of cases involved.)

FORMS:
frmIReview [no record source] just a container form.

SUBFORMS:
sfrmIReview (which is working fine) no link between frmIReview and
sfrmIReview.
sfrmRepackTotals [record source = Repacks]

LABELS:
lblTotalCases=Sum([RepackTotalCases])
lblTotalInvestigations=Count([RepackNumber])

TEXT BOXES:
tbxRepackTotalCases
tbxTotalInvestigations


Here is my code:
Private Sub Form_Load()
Me.lblTotalCases.Caption = Me.tbxRepackTotalCases
Me.lblTotalInvestigations.Caption = Me.tbxTotalInvestigations
vartemp = MsgBox("Total Cases " & Me.tbxRepackTotalCases, vbOKOnly)

End Sub

I left one of the MSGBOX lines in to show how I was trying to determine what
the text box value was. If I step through the code the value is set,
otherwise the text box does not contain a value.

If anyone might suggest where the problem lies, or knows of a better
way.....I am all ears and very grateful.
 
This syntax, which I assume is trying to refer to a control in the subform
itself:
sfrmRepackTotals.tbxRepackTotalCases

is not valid. It must be either
sfrmRepackTotals!tbxRepackTotalCases

or
sfrmRepackTotals.Form.tbxRepackTotalCases
--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
Ken:
Thanks much for your response.
I've tried moving the code around but it causes other problems. Here is the
code I used:

sfrmRepackTotals.lblTotalCases.Caption =
sfrmRepackTotals.tbxRepackTotalCases
sfrmRepackTotals.lblTotalInvestigations.Caption =
sfrmRepackTotals.tbxTotalInvestigations

The error message is:
Method or data member not found.

I tried putting a delay (For i = 1 to 100000) in the open event for the
subform, but that didn't help either. However initially I defined i as an
integer and set the end value to 100,000,000 which caused an overflow error.
After the error message box was closed the values appeared as expected.

What I don't understand about the problem being timing is that this subform
is not related/linked in anyway to either the main form or the other
subform.

I decided to create a Summary Query and used the Count and Sum values to
load the label controls. DUH! Works great. (I was previously calculating the
value directly from the table.)

Review of changes for posterity:
sfrmRepackTotals [record source = qryRepacksSummary] (2 fields in query:
SumRepackTotalCases, CountRepackID)

TEXT BOXES:
tbxRepackTotalCases=SumRepackTotalCases (from qryRepacksSummary)
tbxTotalInvestigations=CountRepackID (from qryRepacksSummary)

LABELS:
lblTotalCases.caption=tbxRepackTotalCases
lblTotalInvestigations.caption=tbxTotalInvestigations

Thanks again for your help.

--
from
Dave the wave~~~~~

Ken Snell said:
Sounds as if there is a timing issue here...your code is running faster
than
the form can load its data.

Is your code running in the main form's Load event procedure? If yes, try
moving the code for setting the values to the form's Activate event. If
that
doesn't work you might try using the Current event of the subform that
runs
the query.

--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
I have a form with 2 subforms. The first subform displays based on an SQL
statement. The second is in the footer of the main form and is only
there
to
display 2 summary numbers from a separate query.

At first I used text boxes and set their values from a query. The problem
was that (even with the tab stops set to no) when the form loaded the cursor
would hide the value. So I added 2 labels to the subform, 2 lines of
code
to
set the labels to the text box values and figured the problem was solved.

When I open the form neither label has a value. If I make the code
break
and
then step through (using F8) the code the values appear as expected???? I've
thrown in some MSGBOX commands to display the values of the text boxes
and
sure enough they are blank, unless I step through the code????

TABLE/FIELD:
Repacks/RepackNumber (reference number for each investigation)
Repacks/RepackTotalCases (number of cases involved.)

FORMS:
frmIReview [no record source] just a container form.

SUBFORMS:
sfrmIReview (which is working fine) no link between frmIReview and
sfrmIReview.
sfrmRepackTotals [record source = Repacks]

LABELS:
lblTotalCases=Sum([RepackTotalCases])
lblTotalInvestigations=Count([RepackNumber])

TEXT BOXES:
tbxRepackTotalCases
tbxTotalInvestigations


Here is my code:
Private Sub Form_Load()
Me.lblTotalCases.Caption = Me.tbxRepackTotalCases
Me.lblTotalInvestigations.Caption = Me.tbxTotalInvestigations
vartemp = MsgBox("Total Cases " & Me.tbxRepackTotalCases, vbOKOnly)

End Sub

I left one of the MSGBOX lines in to show how I was trying to determine what
the text box value was. If I step through the code the value is set,
otherwise the text box does not contain a value.

If anyone might suggest where the problem lies, or knows of a better
way.....I am all ears and very grateful.
 
Thanks again.

That explains the "Method or data member not found." error message. Yes/No?
--
from
Dave the wave~~~~~



Ken Snell said:
This syntax, which I assume is trying to refer to a control in the subform
itself:
sfrmRepackTotals.tbxRepackTotalCases

is not valid. It must be either
sfrmRepackTotals!tbxRepackTotalCases

or
sfrmRepackTotals.Form.tbxRepackTotalCases
--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
Ken:
Thanks much for your response.
I've tried moving the code around but it causes other problems. Here is the
code I used:

sfrmRepackTotals.lblTotalCases.Caption =
sfrmRepackTotals.tbxRepackTotalCases
sfrmRepackTotals.lblTotalInvestigations.Caption =
sfrmRepackTotals.tbxTotalInvestigations

The error message is:
Method or data member not found.

I tried putting a delay (For i = 1 to 100000) in the open event for the
subform, but that didn't help either. However initially I defined i as an
integer and set the end value to 100,000,000 which caused an overflow error.
After the error message box was closed the values appeared as expected.

What I don't understand about the problem being timing is that this subform
is not related/linked in anyway to either the main form or the other
subform.

I decided to create a Summary Query and used the Count and Sum values to
load the label controls. DUH! Works great. (I was previously calculating the
value directly from the table.)

Review of changes for posterity:
sfrmRepackTotals [record source = qryRepacksSummary] (2 fields in query:
SumRepackTotalCases, CountRepackID)

TEXT BOXES:
tbxRepackTotalCases=SumRepackTotalCases (from qryRepacksSummary)
tbxTotalInvestigations=CountRepackID (from qryRepacksSummary)

LABELS:
lblTotalCases.caption=tbxRepackTotalCases
lblTotalInvestigations.caption=tbxTotalInvestigations

Thanks again for your help.

--
from
Dave the wave~~~~~

Ken Snell said:
Sounds as if there is a timing issue here...your code is running faster
than
the form can load its data.

Is your code running in the main form's Load event procedure? If yes, try
moving the code for setting the values to the form's Activate event. If
that
doesn't work you might try using the Current event of the subform that
runs
the query.

--

Ken Snell
<MS ACCESS MVP>

I have a form with 2 subforms. The first subform displays based on an SQL
statement. The second is in the footer of the main form and is only there
to
display 2 summary numbers from a separate query.

At first I used text boxes and set their values from a query. The problem
was that (even with the tab stops set to no) when the form loaded the
cursor
would hide the value. So I added 2 labels to the subform, 2 lines of code
to
set the labels to the text box values and figured the problem was solved.

When I open the form neither label has a value. If I make the code break
and
then step through (using F8) the code the values appear as
expected????
I've
thrown in some MSGBOX commands to display the values of the text boxes
and
sure enough they are blank, unless I step through the code????

TABLE/FIELD:
Repacks/RepackNumber (reference number for each investigation)
Repacks/RepackTotalCases (number of cases involved.)

FORMS:
frmIReview [no record source] just a container form.

SUBFORMS:
sfrmIReview (which is working fine) no link between frmIReview and
sfrmIReview.
sfrmRepackTotals [record source = Repacks]

LABELS:
lblTotalCases=Sum([RepackTotalCases])
lblTotalInvestigations=Count([RepackNumber])

TEXT BOXES:
tbxRepackTotalCases
tbxTotalInvestigations


Here is my code:
Private Sub Form_Load()
Me.lblTotalCases.Caption = Me.tbxRepackTotalCases
Me.lblTotalInvestigations.Caption = Me.tbxTotalInvestigations
vartemp = MsgBox("Total Cases " & Me.tbxRepackTotalCases, vbOKOnly)

End Sub

I left one of the MSGBOX lines in to show how I was trying to
determine
what
the text box value was. If I step through the code the value is set,
otherwise the text box does not contain a value.

If anyone might suggest where the problem lies, or knows of a better
way.....I am all ears and very grateful.
 
Yes, it should.

--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
Thanks again.

That explains the "Method or data member not found." error message. Yes/No?
--
from
Dave the wave~~~~~



Ken Snell said:
This syntax, which I assume is trying to refer to a control in the subform
itself:
sfrmRepackTotals.tbxRepackTotalCases

is not valid. It must be either
sfrmRepackTotals!tbxRepackTotalCases

or
sfrmRepackTotals.Form.tbxRepackTotalCases
--

Ken Snell
<MS ACCESS MVP>

Dave the wave said:
Ken:
Thanks much for your response.
I've tried moving the code around but it causes other problems. Here is the
code I used:

sfrmRepackTotals.lblTotalCases.Caption =
sfrmRepackTotals.tbxRepackTotalCases
sfrmRepackTotals.lblTotalInvestigations.Caption =
sfrmRepackTotals.tbxTotalInvestigations

The error message is:
Method or data member not found.

I tried putting a delay (For i = 1 to 100000) in the open event for the
subform, but that didn't help either. However initially I defined i as an
integer and set the end value to 100,000,000 which caused an overflow error.
After the error message box was closed the values appeared as expected.

What I don't understand about the problem being timing is that this subform
is not related/linked in anyway to either the main form or the other
subform.

I decided to create a Summary Query and used the Count and Sum values to
load the label controls. DUH! Works great. (I was previously
calculating
the
value directly from the table.)

Review of changes for posterity:
sfrmRepackTotals [record source = qryRepacksSummary] (2 fields in query:
SumRepackTotalCases, CountRepackID)

TEXT BOXES:
tbxRepackTotalCases=SumRepackTotalCases (from qryRepacksSummary)
tbxTotalInvestigations=CountRepackID (from qryRepacksSummary)

LABELS:
lblTotalCases.caption=tbxRepackTotalCases
lblTotalInvestigations.caption=tbxTotalInvestigations

Thanks again for your help.

--
from
Dave the wave~~~~~

Sounds as if there is a timing issue here...your code is running faster
than
the form can load its data.

Is your code running in the main form's Load event procedure? If yes, try
moving the code for setting the values to the form's Activate event. If
that
doesn't work you might try using the Current event of the subform that
runs
the query.

--

Ken Snell
<MS ACCESS MVP>

I have a form with 2 subforms. The first subform displays based on
an
SQL
statement. The second is in the footer of the main form and is only there
to
display 2 summary numbers from a separate query.

At first I used text boxes and set their values from a query. The problem
was that (even with the tab stops set to no) when the form loaded the
cursor
would hide the value. So I added 2 labels to the subform, 2 lines of code
to
set the labels to the text box values and figured the problem was solved.

When I open the form neither label has a value. If I make the code break
and
then step through (using F8) the code the values appear as
expected????
I've
thrown in some MSGBOX commands to display the values of the text boxes
and
sure enough they are blank, unless I step through the code????

TABLE/FIELD:
Repacks/RepackNumber (reference number for each investigation)
Repacks/RepackTotalCases (number of cases involved.)

FORMS:
frmIReview [no record source] just a container form.

SUBFORMS:
sfrmIReview (which is working fine) no link between frmIReview and
sfrmIReview.
sfrmRepackTotals [record source = Repacks]

LABELS:
lblTotalCases=Sum([RepackTotalCases])
lblTotalInvestigations=Count([RepackNumber])

TEXT BOXES:
tbxRepackTotalCases
tbxTotalInvestigations


Here is my code:
Private Sub Form_Load()
Me.lblTotalCases.Caption = Me.tbxRepackTotalCases
Me.lblTotalInvestigations.Caption = Me.tbxTotalInvestigations
vartemp = MsgBox("Total Cases " & Me.tbxRepackTotalCases, vbOKOnly)

End Sub

I left one of the MSGBOX lines in to show how I was trying to
determine
what
the text box value was. If I step through the code the value is set,
otherwise the text box does not contain a value.

If anyone might suggest where the problem lies, or knows of a better
way.....I am all ears and very grateful.
 
Back
Top