473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Report Cannot Access Class Object

twinnyfo
3,653 Expert Mod 2GB
Very Strange one here...........

I've created a Class Object, named ManagementLevel.

When I open my DB, it established a new object of that type and assigns various values as needed. I can use this object absolutely anywhere in my DB, as I have made this object Public.

(HIGHLY simplified, but just for demonstration)
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public ML   As New ManagementLevel
  5.  
  6. Public Sub _
  7.     SetDBDefaults()
  8. On Error GoTo EH
  9.  
  10.     ML.Images = "\\SERVER\FOLDER\IMAGES\"
  11.  
  12.     Exit Sub
  13. EH:
  14.     MsgBox "You big dummy!" 
  15.     Exit Sub
  16. End Sub
However, when I have a report, I am unable to use that object:

Expand|Select|Wrap|Line Numbers
  1. Private Sub _
  2.     Detail_Format( _
  3.         Cancel As Integer, _
  4.         FormatCount As Integer)
  5.  
  6.     Me.imgMLShield.Picture = ML.Images & "MLWhite.jpg"
  7.  
  8. End Sub
Compiling produces the error: "Method or data member not found"--even though everywhere else in the DB that has this code, all is fine. In fact, the VBA Editor does not even bring up the possible list of values, either.

After some experimentation, I have determined that at as long as I don't have a Record Source for the Report, all is well. However, as soon as I assign a Record Source, it throws the error.

Any ideas?

Thanks for the hepp!
Apr 30 '20 #1

✓ answered by Rabbit

The only thing that comes to mind is if the record source has a property, method, or field with the same name.

10 3560
NeoPa
32,556 Expert Mod 16PB
Hi Twinny.

If imgMLShield is a bound Image Control then trying to change the value during that event will cause it to complain. A Report doesn't allow changing of data.

I don't exactly know how it manages the Picture property but it seems to treat it almost like it's somehow linked to the data. The PictureType property may also be worth playing with.

All that said, I have an example that works using the ReportHeader_Format() Event Procedure and that works perfectly well for me (Access 2003) with an Image Control. I did notice that in 2003 there is no ControlSource property, thus no concept of a Bound Control as such. In 2010 there is so that may explain the difference in behaviour.
Apr 30 '20 #2
NeoPa
32,556 Expert Mod 16PB
I guess what I should have started with is to suggest you first determine if the issue is related to the Class Object or where in the code it is trying to make changes to the Control.

Try :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print ML.Images
... before the line that crashes and see what you get.
Apr 30 '20 #3
twinnyfo
3,653 Expert Mod 2GB
It really is the strangest thing. The only thing I am changing is whether or not the report has a Record Source. If not, all works well. If so, it doesn't even recognize the existence of that Class Object.

This only seems to affect my reports.
May 12 '20 #4
Access checks to see whether the referenced file is currently loaded in memory.
If the file is not loaded in memory, Access tries to verify that the RefLibPaths registry key exists. If the key exists, Access looks for a named value that has the same name as the reference. If there is a match, Access loads the reference from the path that the named value points to.
Access then searches for the referenced file in the following locations, in this order:
The Application folder (the location of the Msaccess.exe file).
The current folder that you see if you click Open on the File menu.
The Windows or Winnt folder where the operating system files are running.
The System folder under the Windows or Winnt folder.
The folders in the PATH environment variable that are directly accessible by the operating system.
If Access cannot find the file, a reference error occurs.
May 12 '20 #5
twinnyfo
3,653 Expert Mod 2GB
lewish95,

I'm not sure your response had anything to do with the use of Class objects. The issue is that the Report won't even recognize the existence of the class object when I assign a record source to the report.
May 12 '20 #6
NeoPa
32,556 Expert Mod 16PB
Did you try the Debug.Print of ML.Images Twinny? If so what did you see?
May 14 '20 #7
twinnyfo
3,653 Expert Mod 2GB
Neo,

It can’t get there. Again, If my report is unbound (no record source), if I put code in there and start typing ML. the VBA editor gives me a choice of my properties. However, as soon as my report is bound to a record source, I do the same thing, and I just get Value. The code won’t compile, either, as it can’t recognize the variable/statement.

I can use that class object anywhere else freely, just not with a bound report. I’ve even tried beginning with a brand new Report object, with no success.

I did run across this again with another form; but when I created a new form from scratch, it allowed me to use the class object.

This is ALMOST as strange as the form I had once that didn’t allow me to use the Len() function in its code.
May 14 '20 #8
Rabbit
12,516 Expert Mod 8TB
The only thing that comes to mind is if the record source has a property, method, or field with the same name.
May 14 '20 #9
twinnyfo
3,653 Expert Mod 2GB
BINGO!

I knew it had to be something simple! I just made a few changes to the underlying Query and recreated the Report (to shake a hidden connection to the old ML reference) and all is well!

Thanks so much for the hepp!
May 14 '20 #10
Rabbit
12,516 Expert Mod 8TB
No problem! :)
May 14 '20 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Georges Heinesch | last post by:
Hi. This question might seem trivial, but I didn't find any solution. By error, I created some event for a subform (subfrmTest). Hence, an entry in the VBA editor list was made...
3
by: Tracey | last post by:
Hi, there I met a very wierd problem. My startup form say Form1 has a datagrid say datagrid1, when I click an item in datagrid1, I wanna show form2. In my code, I achieved that with: private sub...
3
by: Tracey | last post by:
sorry I post this problem again. I have to stop my work to fix the problem. I'm doing a multi form application(Not a MDI one). My startup form say Form1 has a datagrid say datagrid1, when I...
3
by: Ravindra Tripathi | last post by:
Hi I have a form with a textbox and a close button. whenever I try to close the the form i get an exception "cannot access disposed object named" how do i correct this issue? Ravindra
5
by: Martin Robins | last post by:
I know that this has been asked before; and not only that, I know that it has been answered (successfully) as I myself have previously resolved the problem (with help) - however, I cannot for the...
1
by: Daves | last post by:
I have a custom (derived) Page class called BasePage where I define a class called ImgLink and it has a public constructor: public class ImgLink{ publicImgLink(params...)} From the Masterpage...
2
by: karu | last post by:
Hello All of u Plz help me regarding some problem related c#.net I have two forms form1 and form2 at the load of form1 i call another form2 form1_load() {
0
by: paulnamroud | last post by:
I cannot access class inside ASP.NET Web Application a few seconds ago|LINK Hello, I start to created a new ASP.NET Web Application with VS 2005. I created a sperate folder called "Classes"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.