Hello.
I am trying to change a RecordSource (query) of a subform based on user selection in another form.
In the code below I am setting the same query as defined on the subform (Property RecordSource), but it returns no records at all.
My goal would be to add an "WHERE ID_Avtor = fetchedId", but even the original query does not work. When the code hits I get empty form.
Can anyone help me out?
I am trying to change a RecordSource (query) of a subform based on user selection in another form.
In the code below I am setting the same query as defined on the subform (Property RecordSource), but it returns no records at all.
Code:
Private Sub ID_Click() Dim fetchedId As Integer Dim sql As String With Me.Form.Recordset Me.Parent.Form!IdHolder = .Fields("Id") fetchedId = .Fields("Id") End With sql = "SELECT MT_Pravice.ID AS ID, MT_Pravice.ID_Meta AS ID_Meta, MT_Pravice.ID_Avtor AS ID_Avtor, MT_Pravice.ID_VrstaPravice AS ID_VrstaPravice , MT_Pravice.PravicaPredlagana AS PravicaPredlagana , MT_Pravice.Pravica AS Pravica , MT_Pravice.Opomba AS Opomba, MT_Pravice.Datum AS Datum, MT_Pravice.Datum_Ureditve AS Datum_Ureditve FROM MT_Pravice" Me.Parent!MT_Pravice_DATAFORM.Form.RecordSource = sql Me.Parent!MT_Pravice_DATAFORM.Form.Requery End Sub
Can anyone help me out?
Comment