Sub RecordToScreen()
Dim item As Long
Set RS = New ADODB.Recordset
Statement = "SELECT * FROM tblAsset WHRER AssetID = " & txtAssetID.Text & " picProduct.Picture = LoadPicture(app.path & PictureFileName)"
RS.Open Statement, ConnDB, adOpenForwardOnly, adLockReadOnly, adCmdText
RS.Close:
Set RS = Nothing
End Sub
-------------------------------------------------------------
:'(
Dbug
Run-time error '-2147217900(80040e14)':
Syntax error in FROM clause.

I'm thank beforehand:icon_redface:

Recommended Answers

All 6 Replies

You misspelled WHERE.

I'm sorry 555
Set RS = New ADODB.Recordset
Statement = "SELECT * FROM tblAsset WHERE AssetID = " & txtAssetID.Text & " picProduct.Picture = LoadPicture(app.path & PictureFileName)"
-------------------------------------
Dbug
Run-time error '-2147217900(80040e14)':
Syntax error (missing operator) in quey expression AssetID = " & txtAssetID.Text & " picProduct.Picture = LoadPicture(app.path & PictureFileName


+++help me please

What is the SQL string you are generating? Can you paste in the end result?

Okay,...

You are trying to do two unrelated things with one query statement... and your query structure is incorrect...

This would be correct...

Statement = "SELECT * FROM tblAsset WHERE AssetID = " & txtAssetID.Text

if a number field is what you are querying against...

Now as for the rest of the statement you are trying to execute...

First, quick SQL lesson...

SELECT * FROM tablename WHERE field1 = value AND field2 = value

so your query structure...

...txtAssetID.Text & " picProduct.Picture = ...

is incorrectly formated.

Now, if you debug.print picProduct.Picture with no picture you should recieve 0 in return but if picProduct.Picture does have a picture then you will get a numerical representation...

So, to make a long read shorter, use the query as above, execute it, and then retrieve its values and from what I can guess the PictureFileName is a field name so...

Statement = "SELECT * FROM tblAsset WHERE AssetID = " & txtAssetID.Text
RS.Open Statement, ConnDB, adOpenForwardOnly, adLockReadOnly, adCmdText
picProduct.Picture = LoadPicture(app.path & "\" & RS.Fields("PictureFileName"))
RS.Close


Good Luck

I'm Thanks
But Dbug
No value give for one or more required parameters
RS.Open Statement, ConnDB, adOpenForwardOnly, adLockReadOnly, adCmdText
****adOpenForwardOnly=0****

Without your code it is hard to tell...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.