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

Export Data from Outlook Custom Form to Access

Status
Not open for further replies.

nic6000

MIS
Mar 15, 2007
18
GB
Hi,

I'm having difficulties trying to understand how to export to Access 2000 from Outlook 2000 from a custom form. I'm very new to Outlook struggling to work out what I need to do in VBScript. I have been looking around on the net and have come up with the following which of course doesn’t work - :

Dim dbe
Dim dbs
Dim wks
Dim rst
Dim strNameAndPath
Dim strDBName

Sub cmdTemp_Click()

Set dbe = Item.Application.CreateObject "DAO.DBEngine.36")
strNameAndPath = "H:\Mydata\MI Request Database\SOURCEDATA\MI_SOURCEDATA.mdb"
MsgBox "DBName " & strDBNameAndPath

Set wks = dbe.Workspaces(0)
Set dbs = wks.OpenDatabase(strDBNameAndPath)
Set rst = dbs.OpenRecordset("tblMainData")
rst.AddNew

rst.CustomerName.Value = Item.CustomerName

rst.Update
rst.Close
dbs.Close

End Sub

I'm probably so far off the mark here, can anyone tell me what I need to do to the code to get it working?

I have published the form and other macros are working!

Thanks in advance.

Nic
 
Try this:
Code:
Sub cmdExport_Click() 'cmdExport will be the name of your control

	DbOpenTable = 1
	On Error Resume Next	
	Set Dbe = Application.CreateObject("DAO.DBEngine.36")
	Set myDB = Dbe.Workspaces(0).OpenDatabase("File path to your database")
	Set RS = myDb.OpenRecordset("Your table name",dbOpenTable)

	Rs.AddNew
	Rs("Access Feild Name") = Item.UserProperties.Find("Custom Outlook property").Value
	
	RS.Update
	RS.MoveLast

	RS.Close
	myDB.Close

End Sub

Everybody body is somebodys Nutter.
 
Hi, Thanks very much for that - it works a treat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top