By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Can't update RecordSource of subform

P: 6
I have a combo box that I am using to select a CustomerID from a table called Customers. Once a value has been selected I would like to update the RecordSource property of a sub form called order_entry_frm so that it will filter Order records for that customer. I tried the following...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboCustomer_Change()
  2.   strSQL = "SELECT OrderID, OrderDate, RequiredByDate, DatePaid " & _
  3.   " FROM Orders_tbl " & _
  4.   " WHERE CustomerID=" & Me!cboCustomer.Value & ";"
  5.   Me!order_entry_frm.RecordSource = strSQL
  6.   Me!order_entry_frm.Requery
  7. End Sub
...but got a compiler debug message pointing at line " Me!order_entry_frm.RecordSource = strSQL" which said "Run-time error 438. Object does not support this property or method".

Is there another/better way of doing what I want?

Feb 28 '07 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 10K+
P: 12,324
I believe the correct syntax is Me.order_entry_frm.Form.RecordSource
Feb 28 '07 #2

P: 6
Great, that fixed it.

Many thanks Rabbit.
Feb 28 '07 #3

Expert Mod 10K+
P: 12,324
Not a problem.
Feb 28 '07 #4

Expert Mod 15k+
P: 31,263
A better way to get the results you want would be to use the .Filter property instead, followed by a .requery.
Mar 2 '07 #5

P: 6
Hi Neopa,

How does the Filter proprty work? Is it a way of just appending "criteria" to an existing query?
Mar 11 '07 #6

Expert Mod 15k+
P: 31,263
A report or form object can be called from VBA code, and the fourth parameter of each is called 'WhereCondition'.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
  2. DoCmd.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
Whatever the RecordSource is for the object, it will be further filtered by the 'WhereCondition' parameter.
Mar 12 '07 #7

Post your reply

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