473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strSubFor m)

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 2931
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(strSubFor m).
On 31 Mar 2005 07:29:52 -0800, so**********@ne tzero.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

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

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

Is there something wrong with my references? I have had to shift the
priority of the reference Microsoft Visual Basic for Applications
Exstensibili ty 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
14913
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
25
2906
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 construction and then.. // some other processing and/or changing 'retval' return retval; }
4
2275
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 following is the code of the function: Public Function SubFormRS(FrmTarget As Object) Forms!frmAD_OpeningForm!FrmTarget.RecordSource = "EXEC...
5
5233
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 box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It...
17
3576
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 (*fcmp)() = &cmp_fcn; qsort(..., fcmp); then everything works. But if instead I code qsort as:
10
2952
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 http://allenbrowne.com/ser-56.html and it works great, but I need to unlock and lock my main form and subform separately, using two different buttons.
1
1960
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. function foo2(){} function foo(func){}
12
2570
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 by value temporaries are created?(I'm not touching yet the cases where standard allows optimizations from the side of implementations to avoid...
4
2077
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 problem is that for the final user interface, I had planned to use a "frmDisplay" form which had a number of menu items and then depending on what the...
0
7499
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.