This is code written in Access 2010.
This code is in Microsoft Access Class Objects and the object name is Form_frmMETRIC.
What am I trying to do? I want to filter a file called METRIC by selecting an NID value with a combobox called combo5. The NID value is the primary key in a table called KUseSet. What I see in the combobox is another field which is written in English and has meaning. Combo5 uses the primary key of kUseSet and displays another field which makes sense to the user. After I make the selection, I click the command5 button and should get a filtered list of METRIC. But I don't.
frmMETRIC has a combobox called Combo3. It does not have a Control Source. It has a row Source which reads
SELECT [KUseSet].[NID], [KUseSet].[UseSet] FROM KUseSet ORDER BY [UseSet];
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
' The following statement brings up METRIC with a count of 1 record ready to be a new record.
' I want a filtered list of METRIC; I don't want to input new records to METRIC.
DoCmd.OpenForm "sfrmMETRIC", acNormal, , "NID =" & Me.Combo3.Value
' The following statement causes a form "enter Parameter Value" to appear. I, of course, don't want to give another value. I already selected a value in combo5 and want that value to be used.
' DoCmd.OpenForm "sfrmMETRIC", acNormal, , "sfrmMETRIC.NID =" & Me.Combo3.Value
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
sfrmMETRIC has a table called METRIC. METRIC has a column called NID.
When I select a useset in the combobox, the combobox value is the primary keyin the table KUseSet. Then when I click on the command button I get a window up called "enter Parameter Value." I,of course, don't want this window appearing which wants me to write the code which I have already given the program by selecting a value in combo3. Look at the code above starting with DoCmd.OpenForm......
I just want to select an item in the combobox, click on the command button and get a filtered list of METRIC based on my selection in the combobox.
Obviously,there is something simple I don't understand.
How do I do it? Many thanks.
VBA