HOW DO I CREATE FORM THAT LOOKS UP VALUES IN A TABLE OR QUERY?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

CAN SOMEBODY HELP ME CREATE A FORM THAT FIRST OF ALL, CONTAINS A LIST BOX OR
COMBO BOX THAT WILL SHOW ALL OF THE RECORDS FROM A TABLE; NOW I WANT TO HAVE
A TEXT BOX THAT WILL LOOK UP VALUES IN THAT COMBO OR LIST BOX WITHIN THE
FORM. LAST THING I WANT IS THAT WHEN I CLICK ON THE RECORD I SELECT, A FORM
WILL OPEN DISPLAYING ALL THE INFORMATION IN THAT RECORD (I HAVE ALREADY
CREATED THAT FORM). I DONT KNOW IF I EXPLAINED MYSELF RIGHT BUT PLEASE LET ME
KNOW IF I HAVE TO GIVE FURTHER EXPLANATIONS ON THIS.
 
The easiest way to create a combo box that is populated by the rows of a
table or query is to use the wizard. Enable the wizard in form design view
by selecting View, Toolbox, and toggling on the button with the wand and
stars. Select the Combo box icon from the Toolbox and click and drag to size
the control on the form.

The wizard will launch automatically and walk you through it. Select the
table or query, and all of the columns you want in the box. Be sure to
include the primary key; you will need it to launch your other form. Select
the default "Hide Primary Key Field (recommended)" to display the 2nd column
after the user has made a selection.

To display one of the other columns in a form textbox, use the column
property--set the ControlSource to:

=YourComboBox.Column(index)

where index is the number of the column, beginning with 0, and columns count
whether or not they are displayed.

To launch a new form, place the following code in the combo box' AfterUpdate
event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourFormName"

' Change YourFormName to the name of your 2nd form
' Change PKFieldName to the name of the primary key in the form's
RecordSource
' Change Control to the name of the control on the first form that has
the PK data
' This will, by default, be the first column in your combo box, so
change it to
' the name of your combo box

stLinkCriteria = "[PKFieldName]=" & Me![Control]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 
HEY THAT WAS ACTUALLY PRETTY HELPFUL, NOW THE ONLY THING THAT DIDNT WORK OUT
THE WAY I WANTED IT TO IS THE TEXT BOX....I WANT FOR THE TEXT BOX TO BE EMPTY
AND WHEN I TYPE A CUSTOMERS NAME IN IT, IT WILL HIGHLIGHT IT ON THE COMBO BOX
 
What Andy is trying to say is that typing in all caps is akin to shouting,
and discouraged.

I don't understand what you're trying to do. Seems you can do the same
thing by simply typing into your combo box. Please post more detail about
your intent.

Sprinks
 
hey sprinks thank you for your attention, what i need is to have a list box
of my clients and on top of this list box i want to have a text box that will
highlight the client name on the list box when i type it in. now i know that
this can be done with a combo box but the difference is that a combo box will
not expand until u click on the arrow, a list box will stay expanded. i want
the client list to stay expanded and the text box to be on top. or if u can
tell me a way to keep the combo box expanded that would also be
helpful...thanks
 
I think you can achieve what you want by dropping down the combo box on
getting the focus:

In the OnFocus event procedure:

YourComboBox.Dropdown

Hope that helps.
Sprinks
 
Hey sprinks thanks a lot , that is exacly what i needed. (and just for future
reference, i'm used to writing in caps, i do that all the time at work, its
just a habit, doesnt mean im yelling or anything)
 
what if i only want to use one form, with a combo box listing the current
record of the form.

whenever the combo box changes, the form would change ?

what code would i use then?

Sprinks said:
The easiest way to create a combo box that is populated by the rows of a
table or query is to use the wizard. Enable the wizard in form design view
by selecting View, Toolbox, and toggling on the button with the wand and
stars. Select the Combo box icon from the Toolbox and click and drag to size
the control on the form.

The wizard will launch automatically and walk you through it. Select the
table or query, and all of the columns you want in the box. Be sure to
include the primary key; you will need it to launch your other form. Select
the default "Hide Primary Key Field (recommended)" to display the 2nd column
after the user has made a selection.

To display one of the other columns in a form textbox, use the column
property--set the ControlSource to:

=YourComboBox.Column(index)

where index is the number of the column, beginning with 0, and columns count
whether or not they are displayed.

To launch a new form, place the following code in the combo box' AfterUpdate
event procedure:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourFormName"

' Change YourFormName to the name of your 2nd form
' Change PKFieldName to the name of the primary key in the form's
RecordSource
' Change Control to the name of the control on the first form that has
the PK data
' This will, by default, be the first column in your combo box, so
change it to
' the name of your combo box

stLinkCriteria = "[PKFieldName]=" & Me![Control]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

HOW DO I CREATE A SEARCH FORM???? said:
CAN SOMEBODY HELP ME CREATE A FORM THAT FIRST OF ALL, CONTAINS A LIST BOX OR
COMBO BOX THAT WILL SHOW ALL OF THE RECORDS FROM A TABLE; NOW I WANT TO HAVE
A TEXT BOX THAT WILL LOOK UP VALUES IN THAT COMBO OR LIST BOX WITHIN THE
FORM. LAST THING I WANT IS THAT WHEN I CLICK ON THE RECORD I SELECT, A FORM
WILL OPEN DISPLAYING ALL THE INFORMATION IN THAT RECORD (I HAVE ALREADY
CREATED THAT FORM). I DONT KNOW IF I EXPLAINED MYSELF RIGHT BUT PLEASE LET ME
KNOW IF I HAVE TO GIVE FURTHER EXPLANATIONS ON THIS.
 
Back
Top