Form / Sub Form Coding Question

G

Graham Naylor

Hi,

I have a form on which is a sub form, also on the main form is a combo box,
when I change the value in the combo box I want to change the RecordSource
on the sub form.

I can do most of what I want, there are just 2 lines of code I need help
with, these are attached to the combo box:

They need to be like:

Dim sCriteria as string

sCriteria = [Subform].Recordsource - HELP!

various lines changing sCriteria


[SubForm].Recordsource = sCriteria - HELP!


Thanks in advance for the structure of these lines

Graham
 
B

Beetle

Supposing that the bound column of your combo box stores numeric
values like 1,2,3 you might try something like this in the After Update
event of the combo box;

Dim strSQL As String

Select Case Me!MyCombo
Case 1
strSQL = "Select SomeField From SomeTable"
Case 2
strSQL = "Select SomeDifferentField From SomeDifferentTable"
Case 3
strSQL = "Select SomeThirdField From SomeThirdTable"
End Select

Me![MySubformControl].Form.Recordsource = strSQL
Me![MysubformControl].Form.Requery
 
Top