Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3075

Status
Not open for further replies.

kutibo

MIS
Dec 19, 2000
22
US
I have a form whose record source is a table. I need to retrieve the unitcost from a query by fldVintage and fldSize and save it in the table. My code does not work when there is not match for the fldVintage and fldSize, I get error 3075. Eg.) Syntax error in string in query expression 'fldVintage = 1953 AND fldSize = 4"'.
Here is the code i have thus far thanks for your help.

Dim rst As Recordset, strsql As String

strsql = "select fldsize, fldtype, fldvintage, unitcost from qryCheckCost where fldvintage=" & Me.fldVintage & " AND fldSize = " & Me.fldSize
Set rst = CurrentDb.OpenRecordset(strsql)

getCost = rst.Fields("unitcost")
rst.Close

Kutibo
 
Probably either fldVintage or fldSize is a text field. If so, then surround the value with quotes, like fldVintage = '1953'
e.g.
strsql = "select fldsize, fldtype, fldvintage, unitcost from qryCheckCost where fldvintage='" & Me.fldVintage & "' AND fldSize = " & Me.fldSize

I prefer to have a function that automatically adds the quotes for me (and checks for quotes within the string.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top