Syntax problem - can someone help me please

A

APH

Hi, I am using the code below, but when I run it It am hitt a syntax error
with the '&' (my quotes) on the line below MsgBox "Line1"
This was a suggestion some kind person made in this Ng, my original code is
the line below MsgBox "Line2".

I have tried various combinations but cannot get it right - expect it is a
quotation mark in the wrong place !!

Thanks

Alex




Public Function addLicence()

Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim PS As String

' close seletion form and update purchasers record with licencee
DoCmd.Close acForm, "frmSelOrganisation"
PS = "Show"
MsgBox "Line1"
CurrentProject.Connection.Execute "Update tblSWPurchases SET
[LicenceeName]= & " '" & LName & "'" & " WHERE [SWPurchaseId]=" & SWID

MsgBox "Line2"
CurrentProject.Connection.Execute "Update tblSWPurchases SET
[LicenceeName] ='" & LName & "'WHERE [SWPurchaseId]=" & SWID
CurrentProject.Connection.Execute "Update tblSWPurchases SET [PStatus]
='" & PS & "'WHERE [SWPurchaseId]=" & SWID
CurrentProject.Connection.Execute "Update tblSWPurchases SET
[LicenceeId] ='" & Lid & "'WHERE [SWPurchaseId]=" & SWID

' create licencee record
rs1.Open "tblSWLicences", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
With rs1
MsgBox "hello"
.AddNew
.Fields("RecordId") = RecId
.Fields("LicenceeName") = LName
.Fields("LicenceeId") = Lid
.Fields("SWPurchaseId") = SWID
.Fields("Software") = SW
.Update
End With
rs1.Close

End Function
 
M

Michel Walsh

Hi,


try:


Dim str As String

str= "Update tblSWPurchases SET [LicenceeName]= "'" & LName & "'" & "
WHERE [SWPurchaseId]=" & SWID

' Debug.Print str

CurrentProject.Connection.Execute str





I have remove a single space and an & ( at the left of LName, to get
""", not & " "" ).



Hoping it may help,
Vanderghast, Access MVP
 

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