R
rb608
I used to know the answer to this, but it's been too long since I've
worked with recordsets. So anyway...
I'm trying to create a recordset that isolates a specific record (in
this case, an image file name) using a DAO recordset. The select
criteria are based on fields in an unbound form PhotoData. To
accommodate a few odd variations & formats, I've written the select
strings as follows:
strSelect = "SELECT Images.ImageFile, Images.Description " _
& "FROM Images " _
& "WHERE (ImageFile = Forms!PhotoData!txtPrefix "
strSelect = strSelect & strSpace & strSequence & ")"
For a particular record, that should resolve to the filename "Kirkley
002". To check my work in progress, I have a text box on the form
that receives the string generated by the select string. That string
reads:
SELECT Images.ImageFile, Images.Description FROM Images WHERE
(ImageFile = Forms!PhotoData!txtPrefix &' '&'00'&'2')
In that string, the Forms!PhotoData!txtPrefix should equal "Kirkley"
with the concatenation adding a space and the sequence value " 002".
I've set it up to create a query, and it seems to work fine in that
method, but in trying to open a recordset using:
Set rst1 = db1.OpenRecordset(strSelect, dbOpenDynaset)
I'm getting an error "Too few parameters. Expected 1." From all I've
done so far, I surmise the problem is with the Forms!PhotoData!
txtPrefix portion. What am I doing wrong with the syntax here?
TIA
Joe F.
worked with recordsets. So anyway...
I'm trying to create a recordset that isolates a specific record (in
this case, an image file name) using a DAO recordset. The select
criteria are based on fields in an unbound form PhotoData. To
accommodate a few odd variations & formats, I've written the select
strings as follows:
strSelect = "SELECT Images.ImageFile, Images.Description " _
& "FROM Images " _
& "WHERE (ImageFile = Forms!PhotoData!txtPrefix "
strSelect = strSelect & strSpace & strSequence & ")"
For a particular record, that should resolve to the filename "Kirkley
002". To check my work in progress, I have a text box on the form
that receives the string generated by the select string. That string
reads:
SELECT Images.ImageFile, Images.Description FROM Images WHERE
(ImageFile = Forms!PhotoData!txtPrefix &' '&'00'&'2')
In that string, the Forms!PhotoData!txtPrefix should equal "Kirkley"
with the concatenation adding a space and the sequence value " 002".
I've set it up to create a query, and it seems to work fine in that
method, but in trying to open a recordset using:
Set rst1 = db1.OpenRecordset(strSelect, dbOpenDynaset)
I'm getting an error "Too few parameters. Expected 1." From all I've
done so far, I surmise the problem is with the Forms!PhotoData!
txtPrefix portion. What am I doing wrong with the syntax here?
TIA
Joe F.