By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,122 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,122 IT Pros & Developers. It's quick & easy.

Changing RecordSource in code problem

P: 1

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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_Click()
  2.     Dim fetchedId As Integer
  3.     Dim sql As String
  4.     With Me.Form.Recordset
  5.         Me.Parent.Form!IdHolder = .Fields("Id")
  6.         fetchedId = .Fields("Id")
  7.     End With
  8.     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"
  9.     Me.Parent!MT_Pravice_DATAFORM.Form.RecordSource = sql
  10.     Me.Parent!MT_Pravice_DATAFORM.Form.Requery
  11. End Sub
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?
Apr 24 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,494
You don't share much of the details of your structure, which makes helping you more complicated. What relates to what, and what filtering are you looking for in relation to that?
Apr 27 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.