Solved

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

Posted on 2007-03-31
27
749 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
  • 12
  • 6
  • 5
  • +3
27 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 175 total points
Comment Utility
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 25 total points
Comment Utility
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
Comment Utility
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
 

Author Comment

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

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Just tried Form![WailLbl].Caption  to Form.[WailLbl].Caption...no luck
0
 

Author Comment

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

Expert Comment

by:jefftwilley
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
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
Comment Utility
>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
Comment Utility
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
Comment Utility
I thought that too Mirian...waitlbl
0
 

Author Comment

by:SOTA
Comment Utility
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
Comment Utility
so it was misspelled...oops!
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 25 total points
Comment Utility
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
Comment Utility
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 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 25 total points
Comment Utility
After repaint line have:

DoEvents

to force it to execute your repaint command.

Mike
0
 

Author Comment

by:SOTA
Comment Utility
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 33

Expert Comment

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

Mike
0
 

Author Comment

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

Author Comment

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

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now