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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to .accdb. Add attachment and update table.

Status
Not open for further replies.

GHarmon1977

Technical User
Nov 15, 2012
9
0
0
US
I'm attempting to add an attachment to a MS Access 2010 database via VBScript. But, I do not know the proper syntax for the command, nor can I find it.

.vbs file name: ms.vbs stored on C:from DOS: cscript /nologo C:\ms.vbs

Problem Line: nRS.Fields("Attachments").Value = "C:\ms.txt"

What is the proper syntax for adding an attachment?

Code:
Code:
Set nRS = CreateObject("ADODB.Recordset")
  connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\CR.accdb;"
  sql = "Select * from tbl_ChangeRequests order by ChangeRequestID desc"
  set cn = createobject("ADODB.Connection")

cn.open connectionString

Set RS = cn.Execute(sql)
  NCN = RS("ChangeRequestID") + 1
  WScript.Echo NCN
RS.Close
Set RS = Nothing

nRS.Open "tbl_ChangeRequests", cn, 2, 3
  nRS.AddNew
  nRS.Fields("ChangeRequestID").Value = NCN
  nRS.Fields("Author").Value = "Me"
  nRS.Fields("SignOff_Status").Value = "0"
  nRS.Fields("Attachments").Value = "C:\ms.txt"
  nRS.Update
nRS.Close
Set nRS = Nothing
cn.Close
Set cn = nothing
 
Heh .. How can I credit myself for my own answer!? [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top