473,395 Members | 1,504 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,395 software developers and data experts.

passing subform argument to function

I keep getting an invalid property assignment error when tring to
reference a subform.

All I am trying to do is substitute this:

Forms![frm_ActionItems]![frm_ActionItems_Sub].SetFocus

for this:

FormAndSubForm.SetFocus

Unforturnately no luck thus far. I can't even get this to compile:

Dim strSubForm as string
frmSubForm as form
frmSubForm = Forms(strSubForm)

Is there something wrong with my references? I have had to shift the
priority of the reference Microsoft Visual Basic for Applications
Exstensibility up and down to get other things to work properly. So
I'm wondering if that may be the cause because I see lot's of the above
code referenced in the forum. But I can't get it to compile. What's
up with that? All this headache is just for exporting subform
datasheet to excel. I am using a function posted as "XLPaste" and it
works fine in the form's code but I would like to make a more robust
function out of it by passing the name of the datasheet. If anyone
already has the snippet for this or can point me in the right direction
that would be great. Thanks.

Nov 13 '05 #1
1 2911
There are 3 problems.

First, a subform control isn't a form, it's a control that contains a form.
It's correct to invoke .SetFocus on a subform control, but if you needed to
reference a control on the form within the subform control, you'd need to say
<control>.Form!<controlname>. Dimensioning frmSubForm as Form type is
thus,incorrect. It should be Dim frmSubForm As Subform.

Second, you can't assign a reference to an object by just using <variable> =
<instance>. You have to use the Set keyword: Set <variable> = <instance>

Third, subforms are not in the Access Forms collection, so you can't get a
reference to a subform using Forms(strSubForm).
On 31 Mar 2005 07:29:52 -0800, so**********@netzero.net wrote:
I keep getting an invalid property assignment error when tring to
reference a subform.

All I am trying to do is substitute this:

Forms![frm_ActionItems]![frm_ActionItems_Sub].SetFocus

for this:

FormAndSubForm.SetFocus

Unforturnately no luck thus far. I can't even get this to compile:

Dim strSubForm as string
frmSubForm as form
frmSubForm = Forms(strSubForm)

Is there something wrong with my references? I have had to shift the
priority of the reference Microsoft Visual Basic for Applications
Exstensibility up and down to get other things to work properly. So
I'm wondering if that may be the cause because I see lot's of the above
code referenced in the forum. But I can't get it to compile. What's
up with that? All this headache is just for exporting subform
datasheet to excel. I am using a function posted as "XLPaste" and it
works fine in the form's code but I would like to make a more robust
function out of it by passing the name of the datasheet. If anyone
already has the snippet for this or can point me in the right direction
that would be great. Thanks.


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
4
by: CSDunn | last post by:
Hello, I have a combo box (Combo7) that needs to call a function during the After Update event of the combo box. The function resides in an Access 2000 ADP Module called MMAnswerData_code. The...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
10
by: Ami | last post by:
Hello everyone, I have developed a small access application and now I need to lock my forms against unwanted edits. I have used the code by Allen Browne I found here...
1
by: User1014 | last post by:
Since you can pass a function to a ... erm...... function.... how to you use the result of a function as the argument for another function instead of passing the actual function to it. i.e. ...
12
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned...
4
by: Regnab | last post by:
I've got a form - "frmLookup" (with a subform) that works very happily on its own. The form has a list box, which when updated requeries the subform to display the appropriate results. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.