What I want to do, hopefully, will be simple enough. I want to have a search
form that has two fields, one a combo box and the other an unbound field. I
want the combo box to list the different fields within a table that I want to
search. I want the unbound field to be where I enter the criteria for
searching the field that I selected in the combo box. In the past I usually
just created an unbound form and created unbound fields for each field and
then call the fields to the query. This has always worked well enough but
thought It would be easier using 2 fields as opposed to many. Any help would
be greatly appreciated.
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
vander
|
6/7/2010 7:38:27 PM |
|
Try this --
Your table having Field1, Field2, Field3 and Field4.
Combo having two fields --
1 Field1
2 Field2
3 Field3
4 Field4
Search_Field: IIF([Forms]![YourForm][Cbo1] = 1, Field1,
IIF([Forms]![YourForm][Cbo1] = 2, Field2, IIF([Forms]![YourForm][Cbo1] = 3,
Field3, Field4)))
Criteria: [Forms]![YourForm][Text1]
--
Build a little, test a little.
"vander via AccessMonster.com" wrote:
> What I want to do, hopefully, will be simple enough. I want to have a search
> form that has two fields, one a combo box and the other an unbound field. I
> want the combo box to list the different fields within a table that I want to
> search. I want the unbound field to be where I enter the criteria for
> searching the field that I selected in the combo box. In the past I usually
> just created an unbound form and created unbound fields for each field and
> then call the fields to the query. This has always worked well enough but
> thought It would be easier using 2 fields as opposed to many. Any help would
> be greatly appreciated.
>
> --
> Message posted via http://www.accessmonster.com
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
6/7/2010 9:38:02 PM
|
|
Thanks Karl, I appreciate the help, but one question. How do I set up the
combo box so that it lists field names as opposed to records.
KARL DEWEY wrote:
>Try this --
>Your table having Field1, Field2, Field3 and Field4.
>Combo having two fields --
>1 Field1
>2 Field2
>3 Field3
>4 Field4
>
>Search_Field: IIF([Forms]![YourForm][Cbo1] = 1, Field1,
>IIF([Forms]![YourForm][Cbo1] = 2, Field2, IIF([Forms]![YourForm][Cbo1] = 3,
>Field3, Field4)))
>
>Criteria: [Forms]![YourForm][Text1]
>
>> What I want to do, hopefully, will be simple enough. I want to have a search
>> form that has two fields, one a combo box and the other an unbound field. I
>[quoted text clipped - 5 lines]
>> thought It would be easier using 2 fields as opposed to many. Any help would
>> be greatly appreciated.
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
vander
|
6/7/2010 10:08:12 PM
|
|
vander wrote:
>What I want to do, hopefully, will be simple enough. I want to have a search
>form that has two fields, one a combo box and the other an unbound field. I
>want the combo box to list the different fields within a table that I want to
>search. I want the unbound field to be where I enter the criteria for
>searching the field that I selected in the combo box. In the past I usually
>just created an unbound form and created unbound fields for each field and
>then call the fields to the query. This has always worked well enough but
>thought It would be easier using 2 fields as opposed to many. Any help would
>be greatly appreciated.
You would have to build the filter on the fly... If you open it as a query,
you'd have to use a temporary or stored query that whose SQL property you
could overwrite. The rest is pretty easy....
control source for first combobox:
SELECT Name FROM MSysObjects WHERE Type = 1 AND Name Not Like "MSys*";
control source for second combobox would be a bit more fun...
Private Sub Combo0_AfterUpdate()
PopulateSecondComboWithFieldNames Me.Combo0
End Sub
Private Sub PopulateSecondComboWithFieldNames(ByVal strTable As String)
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim lngIndex As Long
Set tdf = DBEngine(0)(0).TableDefs(strTable)
For Each fld In tdf.Fields
Me.Combo2.AddItem fld.name, Index:=lngIndex
lngIndex = lngIndex + 1
Next fld
End Sub
then you'd have to use these controls to build your SQL statement, and then
you'd probably need to assign the result of that to a holder query's SQL
property... eg
DBEngine(0)(0).QueryDefs("HolderQuery").SQL = <your function to build query>
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
PieterLinden
|
6/7/2010 10:32:33 PM
|
|
|
3 Replies
513 Views
(page loaded in 0.038 seconds)
Similiar Articles: Using a combo box to determine which field to search. - microsoft ...What I want to do, hopefully, will be simple enough. I want to have a search form that has two fields, one a combo box and the other an unbound field. clear a combo box search field - microsoft.public.access.forms ...Using a combo box to determine which field to search. - microsoft ... Have combo box fill several fields on form - microsoft.public ... clear a combo box search field ... How to select query fields based on Combo box? - microsoft.public ...Using a combo box to determine which field to search. - microsoft ... How to select query fields based on Combo box? - microsoft.public ... Pass field value selected in ... Combo Box to select a record and populate fields in a form ...Did you determine if the type of the BoxNo field is Text or Number? Remember that it is common for a combo box ... go to find a record for the form ... using a combo box ... Using a combo box to search for a record - error message ...There's some simple code here: Using a Combo Box to Find ... Access ... 3167 - microsoft.public.access I have a search field for surname in a form using a combo box. Form Combo Box Causes Query Error Message - microsoft.public ...... to determine the ... The combo box for the database that causes no problems is for a "FROM" field on a datasheet form that I use ... is using a combo box & query to search ... How to save data in lookup field from a combobox - microsoft ...I want to save data in a lookup field from a combobox, lookup field and combo data have the same items in the list , furthermore combo box is enable... Combo box to find records - microsoft.public.access.forms ...I have a form and wish to find records using a combo box. Which I know how to do. ... clear a combo box search field - microsoft.public.access.forms ... Aafter I select ... Filtering record using combo box list - microsoft.public.access ...the value selected in the combo box should be equal to a table field. The desired ... like to filter through records on a form using a combo box list. ... at each search ... Combo box returning wrong value - microsoft.public.access ...I am using an option box to determine which sequence to use to present the data (I ... I store the values of the combo box using cbo.column( "field 0 or 1", listIndex ... Using a combo box to determine which field to search. - microsoft ...What I want to do, hopefully, will be simple enough. I want to have a search form that has two fields, one a combo box and the other an unbound field. How to Use Combo Boxes (The Java™ Tutorials > Creating a GUI ...... called the editable combo box, features a text field ... Used by the example to determine which colors to use. ... How to Use Tables (Using a Combo Box as an Editor) How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC ...To determine which Comparator to use for a column, TableRowSorter ... an editor other than a text field, check box, or combo box? ... Shows how to use all list selection modes ... About Combo Boxes - Microsoft Corporation: Software, Smartphones ...The edit selection is the range of selected text, if any, in the selection field of a simple or drop-down combo box. An application can determine the starting ... Access Tutorial 8: Combo Box ControlsIf you want to use a combo box for search, you have ... FIGURE 8.10: Use the wizard to add more than one field to the combo box. ... and events that determine the ... 7/22/2012 5:15:40 AM
|