Your combobox now displays all the PrimKey values. Set the RowSource so as to add another non visible column to your ComboBox which will hold the actual record number related to the PimKey value and set properties to [ColumnCount = 2; ColumnWidths = 1";0"; BoundColumn = 1].
Now in the OnClick event of your ComboBox, place the following code into a code window via the VBEditor.
I am not quite sure what you mean by
"add another non visible column to your ComboBox which will hold the actual record number related to the PimKey value"
how can i find out the actual record number?
hmm. It works now, however only if the records are in ascending order. I mean if the MS Access record number is different from the primary key autonumber it simply jumps to the record number. But I want it to jump to the primary key that I provide. Is there any way to do that?
Another problem is the following. I've provided a screenshot of the error:
The "resource_line subform" is a subform of the "request" form sitting in Request.
So when running the docmd.gotorecord statement i get the error that the resource_line subform is not open.
What can I do?
Hmmm...It's a subform you want to show the record(s) in... try this..
Private Sub cmbShowAllResourceLines_Click()
Forms![Resource_Line Subform].RecordSource = "SELECT * FROM myTableName WHERE myTableName.myTableFieldNameWithPrimKey = '" & Me.cmbShowAllResourceLines & "';"
It seems as though you are trying to set the RecordSource for the RESOURCE Subformcontrol located within the Request Form. The subform control itself does not contain the RecordSource property thus issuing this very error.
You need to set the RecordSource for the actual SubForm itself (located in the Forms section of your databsae window). It to appears to be named RESOURCE Subform.
Dim strQuery As String
StrQuery = "SELECT * FROM Resource WHERE Resource.Res_id = " _
Me.cmbShowAllResources.Coumn(0) & ";"
Forms![RESOURCE Subform].RecordSource = strQuery