-
Sep 13th, 2004, 11:42 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Combo Box to Populate subForm
Needed some help with an afterupdate combo box event. The combo box holds information about building numbers, once a building is selected I would like to populate a subform with all available units. I have two tables, tblBldgs and tblUnits with a propertyid as the key on both. The main form is unbound and the combo box is populated by a select statement.
How can I populate a subform after making a combo box selection?
Thanks
Last edited by root2; Sep 13th, 2004 at 02:53 PM.
-
Sep 13th, 2004, 02:14 PM
#2
Thread Starter
Addicted Member
Followup Code
This is the code I currently have behing the afterupdate combo box "cboPropertyid" on frmPropertyPage3.
AfterUpdate Event
VB Code:
Private Sub cboPropertyid_AfterUpdate()
'Call subroutine to set filter based on selected PropertyID
Call SetFilter
End Sub
Call to SetFilter
VB Code:
Sub SetFilter()
Dim LSQL As String
LSQL = "SELECT * FROM subUnit WHERE subUnit.propertyid = """ & Me.Parent.cboPropertyid & """"
Form_fsubUnitList.RecordSource = LSQL
End Sub
This is what I have on the properties of the form fsubUnitListing
data: SELECT * FROM subUnit WHERE subUnit.propertyid=181;
When I run the application I get the following:
run-time error 2001
You cancelled a previous operation
---> Form_fsubUnitList.RecordSource = LSQL
The information being displayed is the data which I setup in the properties of the fsubUnitListing.
I am completely lost HELP!
-
Sep 13th, 2004, 02:52 PM
#3
Thread Starter
Addicted Member
[RESOLVED]
Wow...figured this silly thing out.
The problem existed with the SELECT statement I had incorrectly added too many quotes causing my SELECT statement to fail. Thanks to everyone for taking a look at my code, this site has always taken me out of jams before but glad to have resolved it myself.
VB Code:
Dim LSQL As String
LSQL = "SELECT * FROM subUnit WHERE subUnit.propertyid = " & Me.cboPropertyid
Form_fsubUnitList.RecordSource = LSQL
Hopefully this posting serves as a good reference to someone in need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|