Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error: 2455 - You entered an expression that has an invalid reference to the property

Posted on 2013-01-03
17
Medium Priority
?
576 Views
Last Modified: 2013-01-10
Been around the world and back on subforms with some great input by the Experts

I'm able to execute a public sub on my subform with this...

Me!MarketingVisitationClient.Form.loadRows

I'm now trying to set a variable to a function on  sub sub form and am getting the error message

This is what I'm executing
 Dim s As String
   
    s = Me!MarketingVisitationClient.Form.MarketingVisitationClientContactsWorklist.Form.sayWhat

The function on the sub sub form is this
Public Function sayWhat() As String
    Set sayWhat = "Larry"
End Function
0
Comment
Question by:lrbrister
  • 5
  • 5
  • 4
  • +1
17 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 38741820
SET only applies to objects.  Try this instead to set a string's value:

Public Function sayWhat() As String
     sayWhat = "Larry"
End Function

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38741823
remove the word "set"

Public Function sayWhat() As String
   sayWhat = "Larry"
End Function
0
 

Author Comment

by:lrbrister
ID: 38741845
hey guys...
I saw that when I placed it in a module and I corrected.
SO I changed in my form and am still getting the same error
(this screen)

Screen
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 61

Expert Comment

by:mbizup
ID: 38741856
Make sure that you are using the name of the subform control (which is possibly different from the name of the subform as seen in the Forms window...
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38741863
Here's a sample...
PublicFunction.mdb
0
 

Author Comment

by:lrbrister
ID: 38741864
mbizup
I am...to make sure I clicked on the frame in the subform.  It and the Subform have the same name
MarketingVisitationClientContactsWorklist
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38741867
what is the name of the subform where the  function sayWhat is ?

try calling the function with this line

Form_nameofSubform.sayWhat
0
 
LVL 75
ID: 38741892
As a test, see if this works:

s = Form_MarketingVisitationClientContactsWorklist.sayWhat
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38741901
;-)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38741911
Just checking... it looks like you are loading your subform at run-time.  Are you doing the same with your sub-subform?

If so, is MarketingVisitationClientContactsWorklist actually loaded as the source object of your sub-sub form at the time you try to execute "sayWhat"?

(If it is not loaded, you will not be able to run that function)
0
 
LVL 75
ID: 38741915
(pages are taking forever to refresh at the moment <sigh>)
0
 

Author Comment

by:lrbrister
ID: 38741916
capricorn and DatabaseMX

This worked...
   s = Form_MarketingVisitationClientContactsWorklist.sayWhat
    MsgBox s

So...How do I use that so that it's unique to each record?

I'm actually running this from the midle for below.
They are all datasheet view forms with a 1 to many as you go deeper in the forms
The one thing that binds them all together is [Client ID]

Form
  Subform
     SubFOrm        (s = Form_MarketingVisitationClientContactsWorklist.sayWhat)
          SubForm
               SubForm( Form_MarketingVisitationClientContactsWorklist)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38741926
<So...How do I use that so that it's unique to each record?>

you may need to pass to the function the value of the unique record or something else..


what are you trying to get as the value returned by the function?
0
 
LVL 75
ID: 38741953
Try this


s= Me.Parent.Parent.Sub1.Form.Sub2.Form.Sub3.Form.MarketingVisitationClientContactsWorklist.Form.sayWhat

Where Sub1,2,3 are the Subform Control Names down that chain ...

mx
0
 

Author Comment

by:lrbrister
ID: 38741958
capricorn1

Well...this journey started with me just trying to access the form.
After about 3 days I discovered that the frame and the subform it was in had different names.

What I'm trying to actually do is run a public routine on that sub form and load data onto it.

I know it seems backwards...but a view or some other linked data source just doesn;t work in this case

So...I would want to run loadData(clientID, visitID)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38743595
Curious -- what is in your LoadData routine that is preventing you from including it in a public module rather than as a function in your sub-sub form?

If you place it in a public module, I would think you could get the line-by-line results simply by setting the control source of a textbox on your middle form to:

= LoadData([clientID], [visitID])

(I don't think you can do this if the function is in your sub-sub form)
0
 

Author Closing Comment

by:lrbrister
ID: 38763616
Folks,
  Sorry for the late get back.

In the end, this answer helped me the most.

Hope I haven't ruffled anyone.  I truly appreciate everyones answer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 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