473,406 Members | 2,387 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,406 software developers and data experts.

access class module from two forms

1
I need help with some VB code. I will keep it generic and clear as possible.

I have two forms lets call Form1 and Form2
I have a class module (CM) and a sub class module (SCM) instantiated in the upper module

CM
|_> SCM

Form 2 loads first and accesses SCM through CM
(everyting OK at this point)
Form 2 calls Form1 which tries to access SCM while Form2 still communicating
to the CM.

Here is the relevent code for Form2:

Private CM_ref As CM

(note everything in Form2 is able to communicate to theCM no problems)

Call Form1.Sub


Here is the relevent code for Form1:

Private Sub Form_Load()

CM_ref.String1 = "String"
(note this is when I receive an invaid use of property error)

End Sub

Public Property Get CM_ref() As CM
Set CM_Ref= CM
End Property

Public Property Let CM_ref (ByRef b As CM)
CM_ref = b
End Property

Here is the relevent code for the CM:

Private m_SCM As clsSCM

Public Property Get SCM() As clsSCM
If m_SCM Is Nothing Then
Set m_SCM = New clsSCM
End If
Set SCM = m_SCM
End Property

Public Property Get String1() As UserDefinedStringType
String1 = SCM.String
End Property

Public Property Let String1(ByVal n As UserDefinedStringType)
SCM.String = n
End Property

Here is the relevent code in SCM:

Private m_String As UserDefinedStringType

Public Property Get String1() As UserDefinedStringType
String1 = m_String
End Property

Public Property Let String1(ByVal int As UserDefinedStringType)
String = int
End Property

Help: What I want to have happen it when Form1 is called and loads,
for Form1 to create a reference to SCM to access it's functions not to
create a new instance of SCM. It should be able to communicate while
Form2 has access to CM.SCM also both would have access to Functions and
update property values that the other form would then see. Any help
or advice would be greatly appreciated. let me know if you need any
other information to figure out what I'm doing wrong to generate this error.
Feb 25 '08 #1
1 1574
Dököll
2,364 Expert 2GB
Hi there!

I am not sure why it is not working but would like to tell you what I think may work.

Form1 should be able to see Form2, if you say something like:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Form1.Text1.Text = Form2.Text1.Text
  3.  
  4.  
Which means that you'd have to tell vb, within the module(s), to talk to Form1/ Form2 fields...

Please continue to stay tuned for added hits on this one.

In a bit!
Feb 26 '08 #2

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

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
4
by: u7djo | last post by:
Hi, I'm currently building an application in Access and as part of this need to import forms and modules from another database. Some of the imports will be revisions of existing forms/modules so I...
2
by: enrio | last post by:
I need to process the source code associated with the forms outside access, and import the changes back to Access. I find that I can export the source code of a form, but when I subsequently...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
5
by: jqpdev | last post by:
Hello all... I'm coming from a Borland Delphi background. Delphi has a specific component called a Data Module. In the designer the Data Module behaves like a windows form. A developer can...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
2
by: Mark Reed | last post by:
Hi All, Using the instructions given from http://www.mvps.org/access/forms/frm0042.htm , I am trying to align 2 forms when the second form is opened. The problem I have is that when compiling the...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.