Re: recordset.clone
- From: John Smith <johnDOTsmithATbromleyhospitalsDOTnhsDOTuk>
- Date: Thu, 02 Oct 2008 13:32:11 +0100
Yes, that is different and would require code.
I assume that your Combo58 has a Row Source something like:
SELECT location_code, location_name FROM locations ORDER BY location_name
If you change that to a UNION query you can add an option for 'All':
SELECT location_code, location_name FROM locations
UNION
SELECT ' ', ' All Locations' FROM locations
ORDER BY location_name
Note the space in from of the description to put it at the top of the list.
Then in the After Update event of the Combo you can put:
Dim SQL as String
SQL = "SELECT some_columns FROM some_tables"
If Me.Combo58 <> " " THEN
SQL = SQL & " WHERE Location = '" & Me![Combo58] & "'"
End IF
Me!SubFormControlName.Form.RecordSource = SQL
Substituting your own column, table and control names. Note that the initial sql assigned to SQL will be the same sql that the subform is currently based on. If this includes a WHERE clause then change the WHERE in the code to AND.
HTH
John
##################################
Don't Print - Save trees
Denver wrote:
I have try this suggestions but no luck. it doesnt sort at all after i select from my combo. the code that i have i used it to sort all records for a certain Location..it works will....
what i want is a code that displays all the records i have in my subform even i have not select a location in my combo? or a code that clears my selection and displays my all my records in the sub-form..
sorry for not elaborating..but thanks this was helpful to me.
"John Smith" wrote:
To do that you need no code at all. Just set the Link Master field property of the sub-form control to Form!Combo58 and the Link Child field to Location.
Note that Location must be part of the Record Source of the sub-form and that if you are using controls rather than columns you cannot use the wizard, you have to type the values in yourself.
HTH
John
##################################
Don't Print - Save trees
Denver wrote:Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Location] = '" & Me![Combo58] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
I have this code.
what code do i need to add so that i can see all the records in my subform after i select from my combo box?
- Follow-Ups:
- Re: recordset.clone
- From: Denver
- Re: recordset.clone
- References:
- Re: recordset.clone
- From: John Smith
- Re: recordset.clone
- From: Denver
- Re: recordset.clone
- Prev by Date: Re: Execute SQL 2005 SSIS Packages
- Next by Date: Re: If "None" then no others, If others then no "None"
- Previous by thread: Re: recordset.clone
- Next by thread: Re: recordset.clone
- Index(es):
Relevant Pages
|