Update to table problem

L

Les

I am using the following to attemp to update my "tblProduct_List" firld
"strDescription"

I keep getting an Undfined variable error.

All the fields are text and the variables show the correct values. I have
also double checked the field names.

Any ideas. I suspect its the "" as I am struggling to get my head round
when you use' ' or " ".


Dim strsql As String
Dim Details As String
Dim Prdt As String
Prdt = strProduct
Details = strDescription

strsql = "UPDATE tblProduct_List SET Description = " & strDescription & "
WHERE Product = '" & Prdt & "'"

CurrentDb.Execute strsql, dbFailOnError
 
M

Marshall Barton

Les said:
I am using the following to attemp to update my "tblProduct_List" firld
"strDescription"

I keep getting an Undfined variable error.

All the fields are text and the variables show the correct values. I have
also double checked the field names.

Any ideas. I suspect its the "" as I am struggling to get my head round
when you use' ' or " ".


Dim strsql As String
Dim Details As String
Dim Prdt As String
Prdt = strProduct
Details = strDescription

strsql = "UPDATE tblProduct_List SET Description = " & strDescription & "
WHERE Product = '" & Prdt & "'"

CurrentDb.Execute strsql, dbFailOnError


This should work:

strsql = "UPDATE tblProduct_List SET Description = """ _
& strDescription & """ WHERE Product = '" & Prdt & "'"

That demonstrates how to use " inside a string as well as
your alternative use of '
 
L

Les

Marshal that works fine thanks

Les

Marshall Barton said:
This should work:

strsql = "UPDATE tblProduct_List SET Description = """ _
& strDescription & """ WHERE Product = '" & Prdt & "'"

That demonstrates how to use " inside a string as well as
your alternative use of '
 
L

Les

Thanks marshall thats great

Marshall Barton said:
This should work:

strsql = "UPDATE tblProduct_List SET Description = """ _
& strDescription & """ WHERE Product = '" & Prdt & "'"

That demonstrates how to use " inside a string as well as
your alternative use of '
 

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