?
Solved

How to repaint a label in a subform from a Function?

Posted on 2007-03-31
27
Medium Priority
?
795 Views
Last Modified: 2008-01-09
In Access97:
I have a function that I call from a subform "InvoiceOrderDetails subform". During the execution of the function, I would like to show progress on a label on the subform.
I have :
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form![WailLbl].Caption = "Establishing Shipping Charges..."
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.Repaint
However, the label does not get repainted and the caption never changes.
Any suggestions?
0
Comment
Question by:SOTA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 6
  • 5
  • +3
27 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 700 total points
ID: 18828950
Try this without the Repaint...
The first line is all you need to change the label caption.
0
 
LVL 34

Assisted Solution

by:jefftwilley
jefftwilley earned 100 total points
ID: 18828951
if you're calling the function from the subform, and the label is on the same subform, then you can refer to the control directly

me.wailLbl.caption = "Establishing Shipping Charges..."
me.refresh

You may also include a Do Events inside your function if you are employing any kind of loop
J
0
 

Author Comment

by:SOTA
ID: 18828980
Sorry Experts but none of these suggestions work.
Tried without the Repaiint...no change
Tried me.wailLbl.caption = "Establishing Shipping Charges..."
Get compile error: "Invalid use of Me key keyword"
Refesh did not work either
I might have to resort to SC = SysCmd(acSysCmdSetStatus, "Establishing Shipping Charges...")
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:SOTA
ID: 18828982
The function is called from the subform with : "Call ShippingAndInsuranceCharges"
and is stored in the Modules area,
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18828996
Then you need the full form reference:

Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.[WailLbl].Caption = "Establishing Shipping Charges..."                                                                        

I doubt this is causing the troble, but I changed Form![WailLbl].Caption  to Form.[WailLbl].Caption

Your syntax looks okay.  Have you added breakpoints to your code to verify that that line is actually being executed?
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18829004
I Agree with Miriam,
Also, what event are you using to "call" your function? A button? Can you paste that code in? Generally speaking, you shouldn't have to use the "call" explitor...
Does the function run as expected?
0
 

Author Comment

by:SOTA
ID: 18829011
I use a button to call the function.
I initially had the function on the sibform itself, but Access97 complained that I had run out of code space! So, I was forced to put it in the module section.

I will try changinf Form![WailLbl].Caption  to Form.[WailLbl].Caption and get right back....

0
 

Author Comment

by:SOTA
ID: 18829014
Just tried Form![WailLbl].Caption  to Form.[WailLbl].Caption...no luck
0
 

Author Comment

by:SOTA
ID: 18829018
yes, I verified that the code is executing as expected...
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18829024
are you trying to update the caption FROM the function?

if the button code looks like this

on_click
Call ShippingAndInsuranceCharges
end sub

can you not change it to be

on_click
me.wailLbl.caption = "Establishing Shipping Charges..."  'Set the Caption
Call ShippingAndInsuranceCharges
me.wailLbl.caption = ""   ' Clear the Caption
end sub
0
 
LVL 44

Expert Comment

by:GRayL
ID: 18829058
Where is the button - on the subForm?  When you put it in a module, a module of the form, or a separate code module.  IE.  did you set the form property has module to Yes, right click on the OnClick event of the button, select Code Builder and insert the code in the Form Module?
0
 

Author Comment

by:SOTA
ID: 18829062
I have
on_click
Call ShippingAndInsuranceCharges
end sub
However, during the function I have nurmerous tables that I update and want to show progress at each stage.
0
 

Author Comment

by:SOTA
ID: 18829073
Button is on Subform.
Module is on Form. On-Click button "CalculateShippingBtn" it calls ShippingAndInsuranceCharges
and the function located in the "Modules" section executes.

Now this is interesting:
I instead put the WaitlLbl on Forms![InvoiceOrderEntry] and then coded
Forms![InvoiceOrderEntry]![WaitLbl].Visible = True
Forms![InvoiceOrderEntry]![WaitLbl].Caption = "Establishing Shipping Charges..."
Forms![InvoiceOrderEntry].Repaint
and it worked perfectly.
It just does not work when I reference the subform!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18829095
The syntax you posted should be okay for a subform:
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.[WailLbl].Caption = "Establishing Shipping Charges..."

Make sure the control names are correct.
>  [InvoiceOrderDetails subform]
This should be the name of the control that 'contains' your subformm which may be different from the name of the actual form...
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18829102
The unusual name that jumps to mubd is this:
>.[WailLbl]

Is this a 'Wail' label,  or a 'Wait' Label?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18829109
>mubd  
That was supposed to  be "mind"
I cant even point out pontential typos without making them myself :-(
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18829112
a way to test to see if you're actually getting to the subform control,

from within your function

msgbox Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.[WailLbl].Caption

this should display the current caption during your function execution. If it doesn't, then you have something named wrong.

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18829115
I thought that too Mirian...waitlbl
0
 

Author Comment

by:SOTA
ID: 18829129
Ha! I also mispelled it as WailLbl earlier on. However, I use the very useful "Build" feature when in code. I right-click anywhere in any code and the Build Wizard comes up. I select the forms, and fields, and properties and paste it in.
Very convenient! I cannot understand why Access200x dropped this feature? One of the reasons I still stick with '97.
Anyhow, I think I got it!
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form![WaitLbl].Caption = "Establishing Shipping Charges..."
Forms![InvoiceOrderEntry].Repaint
does it!
I needed to repaint the parent form, not the subform.
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18829132
so it was misspelled...oops!
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 100 total points
ID: 18829135
it could be a focused issue, set the focus to the subform first

Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].setfocus
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.[WailLbl].setfocus

Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form![WailLbl].Caption = "Establishing Shipping Charges..."
Forms![InvoiceOrderEntry]![InvoiceOrderDetails subform].Form.Repaint
0
 

Author Comment

by:SOTA
ID: 18829140
Nope, the label was not mispelled as the code would give a run-time error on execution. I just mentioned that during my playing around I did mispell WailLbl but the code trapped it.

It is not a focus issue since the button gets and retains focus during the execution.

As I mentioned above, all I needed to do was to repaint the parent form:
Forms![InvoiceOrderEntry].Repaint

That is the solution!
0
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 100 total points
ID: 18829198
After repaint line have:

DoEvents

to force it to execute your repaint command.

Mike
0
 

Author Comment

by:SOTA
ID: 18829205
Again,
Forms![InvoiceOrderEntry].Repaint
does the trick.
Thanks all for your input. I will try to give everyone an assisted answer as I always learn something from everyone.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 18829268
I see you have a solution. Please note DoEvents would make your original code work also.

Mike
0
 

Author Comment

by:SOTA
ID: 18829348
Thanks Mike, I will keep that in mind. :>)
0
 

Author Comment

by:SOTA
ID: 18829350
I used mbizup's answer as accepted one since that was answered first
Hope all is happy!
Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question