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

Search Number Two

P: n/a
OK folks I am having a serious brain fart here and can't get the code
to do what I really want done. I have a form that has a multi-table
query as its data source. The data is dsplayed on the form as a
series of text boxes and combo boxes. I want to have a button that
when clicked will search the previous control (as long as it is one of
the text boxes or combo boxes that contain data) for the text the user
requests. The search should only be performed on the data displayed
in the given previous control. If the previous control is a text box,
the serach should look for the requested text in the bound field. If
the previpous control is a combo box, the serach should look for the
requested text in the field displayed in the combo box, hoever I dont
want it to serach the available values in the combo box, I want it to
search the records for any who have the selected valeu containing the
search text. If it would help any I can put a hidden text box with
the displayed data element of the combo box somewhere on the form.
Anyone want to take a stab at this?

Thanks...

Feb 20 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
DavidB wrote:
OK folks I am having a serious brain fart here and can't get the code
to do what I really want done. I have a form that has a multi-table
query as its data source. The data is dsplayed on the form as a
series of text boxes and combo boxes. I want to have a button that
when clicked will search the previous control (as long as it is one of
the text boxes or combo boxes that contain data) for the text the user
requests. The search should only be performed on the data displayed
in the given previous control. If the previous control is a text box,
the serach should look for the requested text in the bound field. If
the previpous control is a combo box, the serach should look for the
requested text in the field displayed in the combo box, hoever I dont
want it to serach the available values in the combo box, I want it to
search the records for any who have the selected valeu containing the
search text. If it would help any I can put a hidden text box with
the displayed data element of the combo box somewhere on the form.
Anyone want to take a stab at this?

Thanks...
So, let me see if I understand this... you want to know what control the
user previously hit before clicking the command button, and base a query
off that?

This could be fun, if your a bit masochistic (^:

Off the top of my head, this sounds like a fun code project. Create a
global variant in the form's code module to store a control's value.
Next in each of the subject controls you will need to write code in the
Lost_Focus event that stores the value of the control that was exited.

When the button fires, code must build a query to execute on the fly
using the stored value. Since the input type can vary (alpha, numeric,
or Null) you will probably need to build some decision making to create
the query syntax appropriately.

Note also, someone might hit the button without having exited a subject
control, and you will need to account for this also.

Having said all that, this seems an awkward and unintuitive way (from a
user's perspective) to build a query. What's behind this?

--
Smartin
Feb 21 '07 #2

P: n/a
Smartin wrote:
So, let me see if I understand this... you want to know what control
the user previously hit before clicking the command button, and base
a query off that?

This could be fun, if your a bit masochistic (^:

Off the top of my head, this sounds like a fun code project. Create a
global variant in the form's code module to store a control's value.
Next in each of the subject controls you will need to write code in
the Lost_Focus event that stores the value of the control that was
exited.
Or the button's code could just use...

Screen.PreviousControl

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Feb 21 '07 #3

P: n/a
In article <m6*******************@newssvr21.news.prodigy.net> ,
ri*********@hotmail.com says...
Smartin wrote:
So, let me see if I understand this... you want to know what control
the user previously hit before clicking the command button, and base
a query off that?

This could be fun, if your a bit masochistic (^:

Off the top of my head, this sounds like a fun code project. Create a
global variant in the form's code module to store a control's value.
Next in each of the subject controls you will need to write code in
the Lost_Focus event that stores the value of the control that was
exited.

Or the button's code could just use...

Screen.PreviousControl

I know how to use previuoscontrol and in fact my object naming
convention is such that it is easy for me to determine if the previous
control was a text box, combo box, or other object. Other objects would
give the user a message to pick an appropriate field to search on. That
all I have down. What I dont know how to do is simulate the search
functionality of the built in search in access. the find, find next,
etc AND how to do that not only on a text box on the calling form but
also on a combo box (searching on the displayed value rather than the
stored value.
Feb 21 '07 #4

P: n/a
On Feb 20, 9:03 pm, Swans, What Swans? <f...@barkingpumpkin.ooo>
wrote:
In article <m6NCh.46950$Gr2.30...@newssvr21.news.prodigy.net> ,
rickbran...@hotmail.com says...


Smartin wrote:
So, let me see if I understand this... you want to know what control
the user previously hit before clicking the command button, and base
a query off that?
This could be fun, if your a bit masochistic (^:
Off the top of my head, this sounds like a fun code project. Create a
global variant in the form's code module to store a control's value.
Next in each of the subject controls you will need to write code in
the Lost_Focus event that stores the value of the control that was
exited.
Or the button's code could just use...
Screen.PreviousControl

I know how to use previuoscontrol and in fact my object naming
convention is such that it is easy for me to determine if the previous
control was a text box, combo box, or other object. Other objects would
give the user a message to pick an appropriate field to search on. That
all I have down. What I dont know how to do is simulate the search
functionality of the built in search in access. the find, find next,
etc AND how to do that not only on a text box on the calling form but
also on a combo box (searching on the displayed value rather than the
stored value.- Hide quoted text -

- Show quoted text -
David:

Take a look at the FindRecord Action in help for dealing with
searching for records. Note that the field you're going to search in
has to have the focus. Combo boxes are only searchable on the stored
value as far as I know, though you can get what the displayed text of
a combo box is by using the Column property of your combo box if you
want to search some other text field for the displayed text. The
counting of columns is zero based, so column 1 is really 0 and column
2 is 1. So, if you wanted to grab the displayed text of a 2 column
combo box and the first column is your bound column and the second
column is the displayed text, you'd use something like this in your
code:
stMyDisplayedText = Me.MyComboBoxName.Column(1)

HTH,
Jana

Feb 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.