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

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?
SOTAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbizupCommented:
Try this without the Repaint...
The first line is all you need to change the label caption.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jefftwilleyCommented:
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
SOTAAuthor Commented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SOTAAuthor Commented:
The function is called from the subform with : "Call ShippingAndInsuranceCharges"
and is stored in the Modules area,
0
mbizupCommented:
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
jefftwilleyCommented:
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
SOTAAuthor Commented:
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
SOTAAuthor Commented:
Just tried Form![WailLbl].Caption  to Form.[WailLbl].Caption...no luck
0
SOTAAuthor Commented:
yes, I verified that the code is executing as expected...
0
jefftwilleyCommented:
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
GRayLCommented:
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
SOTAAuthor Commented:
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
SOTAAuthor Commented:
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
mbizupCommented:
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
mbizupCommented:
The unusual name that jumps to mubd is this:
>.[WailLbl]

Is this a 'Wail' label,  or a 'Wait' Label?
0
mbizupCommented:
>mubd  
That was supposed to  be "mind"
I cant even point out pontential typos without making them myself :-(
0
jefftwilleyCommented:
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
jefftwilleyCommented:
I thought that too Mirian...waitlbl
0
SOTAAuthor Commented:
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
jefftwilleyCommented:
so it was misspelled...oops!
0
Rey Obrero (Capricorn1)Commented:
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
SOTAAuthor Commented:
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
Mike EghtebasDatabase and Application DeveloperCommented:
After repaint line have:

DoEvents

to force it to execute your repaint command.

Mike
0
SOTAAuthor Commented:
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
Mike EghtebasDatabase and Application DeveloperCommented:
I see you have a solution. Please note DoEvents would make your original code work also.

Mike
0
SOTAAuthor Commented:
Thanks Mike, I will keep that in mind. :>)
0
SOTAAuthor Commented:
I used mbizup's answer as accepted one since that was answered first
Hope all is happy!
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.