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

Combo Box To Search Subform

P: n/a
AW
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!
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
AW wrote:
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.


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 ...

Nov 13 '05 #2

P: n/a
AW
Salad wrote:
AW wrote:
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.
Is Me![occupants].Form![last name] the name of the table field? My


Yes. The [Last Name] field is located in subform.
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.

Searching on [Last Name] in the subform.

BTW, Where is Combo2 at?
In the main form (offices).
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 ...


Thanks, I'll try that.

--
Thanks a million!
Nov 13 '05 #3

P: n/a
AW wrote:
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.
Is Me![occupants].Form![last name] the name of the table field? My

Yes. The [Last Name] field is located in subform.


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.
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.


Searching on [Last Name] in the subform.


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...
BTW, Where is Combo2 at?


In the main form (offices).

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 ...

Thanks, I'll try that.

It should work if you select the table field name to search on for the
value of whatever.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.