Access Report.IsLoaded=true SubReport.IsLoaded=false, why? - ms-access-reports

Hello to all and thanks in advance. I have a Report which gives a list of all projects and then a subreport in the Report Footer that sums the Project Costs over each department. I am trying to access data in that subreport but every time I try:
yr_strt=me.sbrptProposalSummary.Report.lblFY1.caption
I get "Run-time error '2455': You entered an expression that has an invalid reference to the property Form/Report.
Then I tried:
yr_strt=Reports("sbrptProposalOverview").lblFY1.Caption
and I get the error (2451) that the report name is misspelled or refers to a report that isn't open or does't exist.
Which led me to the IsLoaded:
Debug.Print Application.CurrentProject.AllReports("rptProposalOverview").IsLoaded
Debug.Print Application.CurrentProject.AllReports("sbrptProposalOverview").IsLoaded
and I get True and False respectively. What's the deal? So frustrated right now!
Thank You!
Jessica

Jessica - In what event/form is this statement? yr_strt=me.sbrptProposalSummary.Report.lblFY1.caption
Could it be the form isn't loaded when this line is hit?
Excellent coding though! Love to see those calls instead of trying easier and less efficient methods.
Stay frustrated! It is the primary symptom of learning! :)

Related

How to use formula CASE WHEN on Netsuite Oracle?

Hi Can someone help me with the Saved Search: So I’m trying to create a formula(numeric) that would say:
CASE WHEN {internalid} = ‘32319’ THEN 1 ELSE 0 END
— didn’t work it didn’t even show on the description
I also tried:
CASE {internalid} WHEN 32319 THEN 1 ELSE 0 END — also didn’t work and didn’t show on the description.
Not sure if perhaps using formula on my saved search is disabled on my end if so how can I know or check? Or maybe I did not use to correct syntax for the CASE WHEN? The formula is also grayed out(highlighted).
I managed to find a solution. As it turns out I just needed to put a value of 1 on the textbox for Value to validate the CASE WHEN Statement. Also whether there's a single quote for the numbers or in this case without a single quote, it still worked.
Either of those forms should work but your screen shots show a Formula(Text) rather than Formula(Numeric)

VBA application.run, MAc excel 2016

Once again thanks in advance for your help.
I am having trouble using application.run, it does not report any error but the code crashes. The project is big and application.run was the simplest way I found to pass a function as an argument...
I simplified the issue to this:
MsgBox Application.Run("Application.WorksheetFunction.Var_S", ThisWorkbook.Worksheets("Data").Range("B3:B974"))
This is simplified, but I cannot manage to get even this to work.
However the following gives the intended result hence the issue is from the use of application.run and not the var function itself.
MsgBox Application.WorksheetFunction.Var_S(ThisWorkbook.Worksheets("Data").Range("B3:B974"))
Hence I know the issue comes from the way I use application.run. As I said no error is reported but the code stops. nothing is returned and anything after application.run is not executed..
My guess is that I do not have the correct syntax, but I could not find lots of documentations about this. Based on what I read this is supposed to be the correct syntax.
Thanks
Instead of Application.Run you can use
MsgBox CallByName(Application.WorksheetFunction, "Var_S", VbMethod, _
ThisWorkbook.Worksheets("Data").Range("B3:B974"))
Function Var_S returns a value. You're not getting an error because it's running properly. In example #2 you're telling it what to with the returned value. What should it be doing with the response in example #1? If you'd like to simply further as an example, instead the Var_S function, try it with the Now() function, which returns current date: Application.Run "now()" ... again, it runs the function just fine. Application.Run runs a function, whereas MsgBox displays data.

VBScript - RANDOMIZE (Cbyte(Left(Right(Time(),5),2))) throws 500 for ES locales

Using a standard VBScript Randomize statement (below) which works fine -- most of the time.
...RANDOMIZE (Cbyte(Left(Right(Time(),5),2)))
RANDOMIZE...
It took a bit, but in digging thru log files, I've noticed that it throws this 500 error:
Type mismatch: 'Cbyte'
when the users' languages are non-English.
I tried changing the Session.LCID (I'm using Classic ASP) in a test page but no effect.
Any suggestions for fixing or a work-around? Thank you...
It appears you're trying to randomise based on the seconds-within-the-minute value:
12:34:56 AM
|---|
56 AM (right(5))
||
56 (left(2))
Now I have no idea of the top of my head what Time() would return in a Spanish locale, but it may well be something like 12:34:56 de la mañana.
What I do know is that relying on a specific presentation format in a globalised world is a bad idea. In your case, it may involve trying to convert left(right("12:34:56 de la mañana",5),2), or "añ", into a numeric value, something it's not going to be happy with.
If you want a true root cause analysis, I'd suggest catching the conversion error and actually logging what Time() is presenting itself as when it errors.
If you just want to fix it, find a way to get the seconds that doesn't depend on locale, for example:
secs = Second(Time())
As an aside, I'm not sure why you think this is even needed. The documentation for the VBScript Randomise function states that, if an argument is not given, the value returned by the system timer is used as the new seed value. Hence it's already based on the current time.

HP UFT (Unified Functional Testing) : Results View : Is there a way to capture the row, line number of the script where it failed?

I usually report the events when it passes or fails like:
Reporter.ReportEvent micPass," Title of the passed Event", " Description of Passed Event"
And
Reporter.ReportEvent micFail," Title of the failed Event", " Description of Failed Event"
Is it a good idea to hard code the line number in the title or description of the event like ?
Reporter.ReportEvent micFail," Test Failed at Line 432 ", " Please check line 432 "
To answer the 2nd part of your question, hard-coding will not be a good idea. If you hard-code the line number and in the future, a few lines get added to the code above that line number, the whole point hard-coding goes in vain as the report will now contain the incorrect-line number(which was hard-coded).
And for the first part, I can understand why you want the line-number to be reported. But I don't think there is any "predefined" way of doing it.
But, you can make your own function to get the line number. Here's an idea that you can implement:
Go to the location where your QTP test is stored. Get the full path of the file script.mts(you can find it inside the Action1 Folder). Also, this path can be constructed dynamically if you have good framework and proper folder structure.
After getting the path, you can open that file(script.mts) as a text stream(using the filesystemobject) in Read only mode.
Now you can traverse through the file line-by-line searching for the text "Reporter.ReportEvent micPass," Title of the passed Event", " Description of Passed Event"". After you have found it, you can easily get the line number and return that from your function to store it in some variable which you can use while reporting.
I have not tried this method myself but would have surely given it a try, If I really needed it.
Hardcoding is not a good idea from an end user perspective. In case it's a regression suite it could be used by a tester who doesn't know how to debug the code or analyze. To get the root cause of the failure through reporting (micPass/micFail) you can further refine your scripts

Insert Property of Picture Class

I have read all of the questions on here about this topic and none of them provided me with a workable solution, so I'm asking this one.
I am running a legitimate copy of Excel 2013 in Windows 7. I record a macros where I insert a picture, and in the open file dialog I paste this URL: http://ecx.images-amazon.com/images/I/41u%2BilIi00L._SL160_.jpg (simply a picture of a product on Amazon). This works as expected.
The resulting macros looks like this:
Sub insertImage()
'
' percent Macro
'
'
ActiveSheet.Pictures.Insert( _
"http://ecx.images-amazon.com/images/I/41u+ilIi00L._SL160_.jpg").Select
End Sub
However, when I attempt to run this, the Insert line breaks with the following error:
Run-time error '1004':
Unable to get the Insert property of the Picture class
I am trying to insert a number of pictures into an excel document and I am using the ActiveSheet.Pictures.Insert method to do this. I have been experiencing this issue there, so I recreated it in a way others could replicate to facilitate getting an answer...
An interesting thing to note is:
http://ecx.images-amazon.com/images/I/41u%2BilIi00L._SL160_.jpg 'This is what I pasted
http://ecx.images-amazon.com/images/I/41u+ilIi00L._SL160_.jpg 'This is what the recorded macros recorded
It looks like Excel automatically resolved the %2B to a +. I tried making that change, but to no success.
Another interesting thing to note is that sometimes this does work and sometimes it doesn't. This url is a case where it does not work. Here's one where it does: http://ecx.images-amazon.com/images/I/51mXQ-IjigL._SL160_.jpg
Why would Excel generate a macros it can't run? More importantly, how can I avoid this error and get on with my work!? Thanks!
Try this workaround:
Sub RetrieveImage()
Dim wsht As Worksheet: Set wsht = ThisWorkbook.ActiveSheet
wsht.Shapes.AddPicture "http://ecx.images-amazon.com/images/I/41u+ilIi00L._SL160_.jpg", _
msoFalse, msoTrue, 0, 0, 100, 100
End Sub
All fields are required, which is kind of a bummer since you cannot get the default size. The location offsets and sizes are in pixels/points. Also, the % turning to + is just alright, as % would cause it to be not recognized (dunno why).
Result:
Let us know if this helps.
I'm experiencing the same issue.
After some digging I found out Excel does a HTTP HEAD request before getting the image.
If this HEAD request is unsuccessful Excel will return the exact error messages mentioned in this discussion.
Your could easily test this using Fiddler.

Resources