Hi! I am trying to change the RecordSource for a subform based on what the user chooses from a combo box. code looks like this:
Set rst = db.OpenRecordset("SELECT LeftAssy FROM [Job Q] WHERE ( JOB = '" & Me![Combo0] & "' )"
If (rst!LeftAssy = "78364" Then
Me.RecordSource = "BTB Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, Classification.[PART NO], Classification.DESCRIPTION, Classification.Class, Classification.Link, Classification.OP FROM [Pick List] INNER JOIN Classification ON [Pick List].COMPONENT = Classification.[PART NO] WHERE ((([Pick List].QNTY)<>0) AND ((Classification.Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND ((Classification.OP)=10)) OR ((([Pick List].QNTY)<>0) AND ((Classification.Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND ((Classification.Link)<>[Part No]) AND ((Classification.OP)=10));"
ElseIf (rst!LeftAssy = "70160" Then
Me.RecordSource = "160 Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, [160 Classification].[PART NO], [160 Classification].DESCRIPTION, [160 Classification].Class, [160 Classification].Link, [160 Classification].OP FROM [Pick List] INNER JOIN [160 Classification] ON [Pick List].COMPONENT = [160 Classification].[PART NO] WHERE ((([Pick List].QNTY)<>0) AND (([160 Classification].Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND (([160 Classification].OP)=10)) OR ((([Pick List].QNTY)<>0) AND (([160 Classification].Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND (([160 Classification].Link)<>[Part No]) AND (([160 Classification].OP)=10));"
ElseIf (rst!LeftAssy = "70360" Then
Me.RecordSource = "360 Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, [360 Classification].[PART NO], [360 Classification].DESCRIPTION, [360 Classification].Class, [360 Classification].Link, [360 Classification].OP FROM [Pick List] INNER JOIN [360 Classification] ON [Pick List].COMPONENT = [360 Classification].[PART NO] WHERE ((([Pick List].QNTY)<>0) AND (([360 Classification].Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND (([360 Classification].OP)=10)) OR ((([Pick List].QNTY)<>0) AND (([360 Classification].Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND (([360 Classification].Link)<>[Part No]) AND (([360 Classification].OP)=10));"
End If
[Forms]![major 10 fm].RecordSource = sqlst
I am getting an error on the [Forms]![major 10 fm].RecordSource line. Error is #2450: Can't find the form 'Major 10 fm' refered to in code.
Any ideas?
Thanks!
-Brad
Set rst = db.OpenRecordset("SELECT LeftAssy FROM [Job Q] WHERE ( JOB = '" & Me![Combo0] & "' )"
If (rst!LeftAssy = "78364" Then
Me.RecordSource = "BTB Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, Classification.[PART NO], Classification.DESCRIPTION, Classification.Class, Classification.Link, Classification.OP FROM [Pick List] INNER JOIN Classification ON [Pick List].COMPONENT = Classification.[PART NO] WHERE ((([Pick List].QNTY)<>0) AND ((Classification.Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND ((Classification.OP)=10)) OR ((([Pick List].QNTY)<>0) AND ((Classification.Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND ((Classification.Link)<>[Part No]) AND ((Classification.OP)=10));"
ElseIf (rst!LeftAssy = "70160" Then
Me.RecordSource = "160 Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, [160 Classification].[PART NO], [160 Classification].DESCRIPTION, [160 Classification].Class, [160 Classification].Link, [160 Classification].OP FROM [Pick List] INNER JOIN [160 Classification] ON [Pick List].COMPONENT = [160 Classification].[PART NO] WHERE ((([Pick List].QNTY)<>0) AND (([160 Classification].Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND (([160 Classification].OP)=10)) OR ((([Pick List].QNTY)<>0) AND (([160 Classification].Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND (([160 Classification].Link)<>[Part No]) AND (([160 Classification].OP)=10));"
ElseIf (rst!LeftAssy = "70360" Then
Me.RecordSource = "360 Pick List Q"
sqlst = "SELECT [Pick List].JOB, [Pick List].QNTY, [360 Classification].[PART NO], [360 Classification].DESCRIPTION, [360 Classification].Class, [360 Classification].Link, [360 Classification].OP FROM [Pick List] INNER JOIN [360 Classification] ON [Pick List].COMPONENT = [360 Classification].[PART NO] WHERE ((([Pick List].QNTY)<>0) AND (([360 Classification].Class)=" & Chr$(34) & "Major" & Chr$(34) & " AND (([360 Classification].OP)=10)) OR ((([Pick List].QNTY)<>0) AND (([360 Classification].Class)=" & Chr$(34) & "Subassy" & Chr$(34) & " AND (([360 Classification].Link)<>[Part No]) AND (([360 Classification].OP)=10));"
End If
[Forms]![major 10 fm].RecordSource = sqlst
I am getting an error on the [Forms]![major 10 fm].RecordSource line. Error is #2450: Can't find the form 'Major 10 fm' refered to in code.
Any ideas?
Thanks!
-Brad