Combo Box Lookup problem

G

Guest

I created a simple form with a combo box in the header that I would like to
use to select a Project ID Number from a Projects Table. Then I want the form
to update to the selected ProjectID. I have the following code in the Combo
box OnClick property.

Private Sub cboFilter_Click()
Dim strSQL As String
strSQL = "SELECT * FROM Projects " & _
"WHERE ProjectID = " & cboFilter.Column(0)
Debug.Print strSQL
Forms!ProjectsCombo.RecordSource = strSQL
End Sub

When I select the ProjectID in the Combo box I get a message box that asks
me to "Enter Parameter Value" and yet the value that I selected is shown. The
SQL query seems to be Okay as the Immediate window shows the correct Project,
but why am I getting this parameter value message.

Thanks in advance for any help you may have.

Brian
 
L

Larry Linson

I created a simple form with a combo
box in the header that I would like to
use to select a Project ID Number
from a Projects Table. Then I want
the form to update to the selected
ProjectID. I have the following code
in the Combo box OnClick property.

The functionality you want is called "query by form" abbreviated as QBF.
There used to be a help topic on QBF, but now it is just one of the options
in the Combo Box Wizard. I think, if you'll create another Combo Box with
the Wizards active (the picture of the "magic wand" in the toolbox will
appear depressed), and choose the correct option, that it will write the
code for you.

As Van said, the code should be in the Combo Box's AfterUpdate event, and
that is where the Wizard will put it.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top