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

Access can't find subform

I'm using a search engine in VBA to return a new RecordSource to a SubForm, but when I attempt to apply the new SQL code as the RecordSource to the SubForm which contains the data the user wants to see, Access (VBA) returns an error that the form can't be found (even though the form is open and displayed on the screen).

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. If Trim(txtMaterialNumber.Text) = "" Then
  2.          MsgBox "Criteria Must Be Entered Before Performing A Search", 
  3.           vbInformation, "Enter Criteria"        
  4. Else
  5.         strRecordSource = SetupOperatingSuppliesSearchQuery(True, False, 
  6.         Forms![OperatingSupplies].Form.RecordSource = strRecordSource
  7. End If
  8.  
  9.  
  10. Forms![OperatingSupplies].Form.RecordSource = strRecordSource
  11.  
  12. Me.Requery
Dec 22 '08 #1
9 7976
FishVal
2,653 Expert 2GB
Is your [OperatingSupplies] form in datasheet view?
Dec 22 '08 #2
DonRayner
489 Expert 256MB
You need to refer to the subform by refering to it's main form first

Expand|Select|Wrap|Line Numbers
  1. Forms!MainForm.Form!OperatingSupplies.RecordSource = strRecordSource
  2.  
Dec 22 '08 #3
No, the main form is a "container" form which has 3 subforms. It is layed-out in an Outlook style with some icons running down the left side, continous form data in the middle form, and then a search engine form at the top.

They are also all independent of each other (in other words, no keys or data fields tying any of the 3 together). Everything will be handled in code.
Dec 22 '08 #4
FishVal
2,653 Expert 2GB
Sorry, didn't pay attention to hoe you get reference to it.
Take a look at DonRayner's suggestion.
Form opened in a subform control is not been added to Forms collection.
So, it should be referenced via Form property of the subform control.

Regards,
Fish
Dec 22 '08 #5
Don,

I tried the code you posted and I received an 'Object does not support this property or method' error (after inserting the name of my mainform in place of the code you sent first of course). I can't remember how to do this because I've been away from Access coding for so long.
Dec 22 '08 #6
I figured out a solution:
Expand|Select|Wrap|Line Numbers
  1.     Dim frm As Form_OperatingSupplies
  2.  
  3.     Set frm = Form_OperatingSupplies
  4.  
  5.     frm.RecordSource = strRecordSource
  6.  
  7.     frm.Requery
Seems to be working perfectly. Thanks for the help though. It set me on the right path to my solution after realizing that the form needed to be dimensioned as it's own individual Object.

-Chris
Dec 22 '08 #7
NeoPa
32,556 Expert Mod 16PB
Referring to Items on a Sub-Form may help with such references.

Welcome to Bytes!
Dec 22 '08 #8
Chickenhawk if you ever revisit this post, your own solution sorted my similar problem which had cost me hours. Many thenks!
Aug 12 '10 #9
NeoPa
32,556 Expert Mod 16PB
Always nice to hear when people find anything we have to be helpful BP.

Thanks for posting and welcome to Bytes!
Aug 12 '10 #10

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

Similar topics

7
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals....
8
by: deko | last post by:
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties. First, I have a record set with the...
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...
2
by: Terry | last post by:
Hello, I wonder if anyone can shed light on this problem for me. I have an Access 97 front end with an SQL 2000 database. There is a Business main form with an Owner subform and corresponding...
1
by: Thomas Zimmermann | last post by:
I have a form with a subform in datasheet view. Now, I want to trigger a procedure (P1) each time the user selects an entire column (by clicking in the heading) in the subform. The procedure (P1) I...
20
by: TC | last post by:
I need an automated procedure to copy data from an Access table to a SQL Server table. Speed is important. What is the recommended technique? I can export the data from Access, copy it via FTP,...
1
by: ashkash | last post by:
I have an access database which takes information from a user and then uses the mail merge functionality to merge the data into a word document. I have a lot of subforms in the access database which...
11
by: BobBanks | last post by:
Hi, Im making a db for my company in Access 2003 usin xp sp2. Ive created an orders form that has a subform in it. The Order form (parent(is linked to a Orders Qry)) and the Orders Subform...
5
Scott Price
by: Scott Price | last post by:
Hello, I'm running Access 2003 trying to filter a subform with approximately 15 records per year per the main record contained on the parent form. The filter works fine if the subform is opened...
5
by: CindySue | last post by:
I'm using a subform linked to the main form by a bidder number field. In the subform, I added a group header and put the field LS in it so that it would list all records designated as Live first...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...
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.