Solved

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

Posted on 2007-03-31
27
762 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
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 25 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
 

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 25 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 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 25 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 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

867 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

16 Experts available now in Live!

Get 1:1 Help Now