
November 13th, 2005, 12:10 AM
| | | Combo Box To Search Subform
Hi all,
I have a form (named Offices) with a subform (named Occupants) that connect
with the Master/Child Field "office number". I have a combo box that allows
a user to pull up a particular office and see the listing of its occupants,
no problem.
Next, I tried to create a combo box that would allow users to search for a
particular occupant within the subform regardless of which office was
selected. However, nothing happens. At least I'm not getting any error
messages.
Here's the code in the main (Offices) form:
Me.RecordsetClone.FindFirst " '" & Me![occupants].Form![last name] & "' =
'" & Me![Combo2] & "' "
Any ideas will be greatly appreciated.
--
Thanks a million! | 
November 13th, 2005, 12:10 AM
| | | Re: Combo Box To Search Subform
AW wrote:
[color=blue]
> Hi all,
>
> I have a form (named Offices) with a subform (named Occupants) that connect
> with the Master/Child Field "office number". I have a combo box that allows
> a user to pull up a particular office and see the listing of its occupants,
> no problem.
>
> Next, I tried to create a combo box that would allow users to search for a
> particular occupant within the subform regardless of which office was
> selected. However, nothing happens. At least I'm not getting any error
> messages.
>
> Here's the code in the main (Offices) form:
>
> Me.RecordsetClone.FindFirst " '" & Me![occupants].Form![last name] & "' =
> '" & Me![Combo2] & "' "
>
> Any ideas will be greatly appreciated.
>
>[/color]
Is Me![occupants].Form![last name] the name of the table field? My
code may look more like this
Me.recordsetclone.findfirst "[LastName] = '" & Me.Combo2 & "'"
because I usually know the field name I am searching on.
You may want to step through your code and determine what the heck you
are searching on if you don't know what field you are searching.
BTW, Where is Combo2 at? In the main or sub form? If on the MainForm,
I doubt you'd find it anyway if you are looking for records in the
subform. You might have to do something like (air code, not tested)
Me.SubformName.Form.Recordsetclone.FindFirst ... | 
November 13th, 2005, 12:10 AM
| | | Re: Combo Box To Search Subform
Salad wrote:
[color=blue]
> AW wrote:
>[color=green]
>> Hi all,
>>
>> I have a form (named Offices) with a subform (named Occupants) that
>> connect with the Master/Child Field "office number". I have a combo box
>> that allows a user to pull up a particular office and see the listing of
>> its occupants, no problem.
>>
>> Next, I tried to create a combo box that would allow users to search for
>> a particular occupant within the subform regardless of which office was
>> selected. However, nothing happens. At least I'm not getting any error
>> messages.
>>
>> Here's the code in the main (Offices) form:
>>
>> Me.RecordsetClone.FindFirst " '" & Me![occupants].Form![last name] & "' =
>> '" & Me![Combo2] & "' "
>>
>> Any ideas will be greatly appreciated.
>>
>>[/color]
>
> Is Me![occupants].Form![last name] the name of the table field? My[/color]
Yes. The [Last Name] field is located in subform.
[color=blue]
> code may look more like this
> Me.recordsetclone.findfirst "[LastName] = '" & Me.Combo2 & "'"
> because I usually know the field name I am searching on.
>
> You may want to step through your code and determine what the heck you
> are searching on if you don't know what field you are searching.
>[/color]
Searching on [Last Name] in the subform.
[color=blue]
> BTW, Where is Combo2 at?[/color]
In the main form (offices).
[color=blue]
> In the main or sub form? If on the MainForm,
> I doubt you'd find it anyway if you are looking for records in the
> subform. You might have to do something like (air code, not tested)
> Me.SubformName.Form.Recordsetclone.FindFirst ...[/color]
Thanks, I'll try that.
--
Thanks a million! | 
November 13th, 2005, 12:10 AM
| | | Re: Combo Box To Search Subform
AW wrote:
[color=blue][color=green][color=darkred]
>>>Here's the code in the main (Offices) form:
>>>
>>>Me.RecordsetClone.FindFirst " '" & Me![occupants].Form![last name] & "' =
>>>'" & Me![Combo2] & "' "
>>>
>>>Any ideas will be greatly appreciated.
>>>
>>>[/color]
>>
>>Is Me![occupants].Form![last name] the name of the table field? My[/color]
>
>
> Yes. The [Last Name] field is located in subform.[/color]
Is the value of [Last Name] the name in the table field? I suspect
right now you are saying something like "Please find table field Smith
where the value is equal to Smith"
You really need to search of the table field name, not the table field
value.
[color=blue][color=green]
>>code may look more like this
>>Me.recordsetclone.findfirst "[LastName] = '" & Me.Combo2 & "'"
>>because I usually know the field name I am searching on.
>>
>>You may want to step through your code and determine what the heck you
>>are searching on if you don't know what field you are searching.[/color]
>
> Searching on [Last Name] in the subform.[/color]
I think you are confused on what a table/query field is and a value
contained in a field.
Example. I might have a field called FirstName. In a record in the
table, I might have a record where the value of first name is "Salad" I
would search the table field name FirstName for the value of Salad. I
would not search for a field name of Salad for the value of Salad. Now
if I had a table field name of Salad...
[color=blue]
>[color=green]
>>BTW, Where is Combo2 at?[/color]
>
> In the main form (offices).
>
>[color=green]
>>In the main or sub form? If on the MainForm,
>>I doubt you'd find it anyway if you are looking for records in the
>>subform. You might have to do something like (air code, not tested)
>>Me.SubformName.Form.Recordsetclone.FindFirst ...[/color]
>
>
> Thanks, I'll try that.
>[/color]
It should work if you select the table field name to search on for the
value of whatever. |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|