Setting RecordSource on Subform

G

Guest

Hi! I've been looking at other questions posted here and have tried to
replicate one of the solutions proposed with no success.
I have a form and an (unlinked) subform. When users select a value from the
combo I want to set the Record Source for the subform to an SQL string which
uses said value ie SQLstring = "Select JobID FROM Job (where JobID = " &
cmbo.Value & ")" At present I get Error 30025 - 'Invalid SQL string. Check
Server Filter on Form record source.'
I don't have any filters (either on the form or on the server) I have
Debug.Printed my SQL and it looks fine .... Please, what am I doing wrong?
 
R

Rob Parker

Try
SQLstring = "Select JobID FROM Job where (JobID = " & cmbo.Value & ")"

You've got the opening ( before the WHERE, rather than after. You could
omit the bracketing here, since it's not needed to force an evaluation
order. You may also need a closing ; in the SQL string. All of this may
mean that what you really need is:
SQLstring = "Select JobID FROM Job where JobID = " & cmbo.Value & ";"

HTH,

Rob

Jim Scarlett said:
Hi! I've been looking at other questions posted here and have tried to
replicate one of the solutions proposed with no success.
I have a form and an (unlinked) subform. When users select a value from the
combo I want to set the Record Source for the subform to an SQL string which
uses said value ie SQLstring = "Select JobID FROM Job (where JobID = " &
cmbo.Value & ")" At present I get Error 30025 - 'Invalid SQL string. Check
Server Filter on Form record source.'
I don't have any filters (either on the form or on the server) I have
Debug.Printed my SQL and it looks fine .... Please, what am I doing
wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top