Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2015, 08:07 AM
crowndale crowndale is offline Update .accdb file from within Word vba Windows 7 64bit Update .accdb file from within Word vba Office 2013
Novice
Update .accdb file from within Word vba
 
Join Date: Jul 2015
Location: Bristol UK
Posts: 1
crowndale is on a distinguished road
Thumbs down Update .accdb file from within Word vba

I wrote, and have been using, Word VBA for some time with an early version of Access (.mdb suffix), and all works fine. I want to change it to use the current Access .accdb suffix. I've tried just changing the suufix from .mdb to .accdb but that gives an error "User defined type not defined" when it tries to execute "dbs As DAO.database".

Any help will be very much appreciated as I'm now out of my depth! Relevant scraps of code are shown below.

Option Explicit
Dim MasterDbDrive As String

Private Sub UserForm_Initialize()
MultiMaxCount = 10 ' maximum prints that can be held before printing
'NetworkReply = 0
MasterDbDrive = "C:" ' set to C: for testing on a local PC
RootFolder = MasterDbDrive + "\Helpline Docs\Standard Letters\"
MasterFolder = RootFolder & "Master copies\" 'path of master documents
PrevFolder = RootFolder & "Previous versions\" 'to save previous letter
MasterDb = MasterFolder & "Standard Letters.mdb"

FFUI_Start:
On Error GoTo FFUIerr1
ChDrive MasterDbDrive
GoTo FFUIerr1x



-----------------------------------------------------------------------------------------------------

Private Sub WriteToDB()
Dim dbs As DAO.database
Dim rst As DAO.recordset
Set dbs = OpenDatabase(Name:=MasterDb)
Set rst = dbs.OpenRecordset(DbTable, dbOpenTable)
With rst
.AddNew
.Fields("Addressee") = FrmMainB.Addressee
.Fields("Position") = FrmMainB.Position
.Fields("Organisation") = FrmMainB.Organisation
.Fields("Address1") = FrmMainB.Address1
.Fields("Address2") = FrmMainB.Address2
.Fields("Address3") = FrmMainB.Address3
.Fields("Address4") = FrmMainB.Address4
.Fields("PostCode") = FrmMainB.PostCode
.Fields("Salutation") = FrmMainB.Salutation
.Update
End With
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
Reply With Quote
Reply

Tags
.accdb access word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update .accdb file from within Word vba Have Powerpoint dynamically update from an excel or other file? oshkosh PowerPoint 3 04-05-2016 06:10 AM
Update .accdb file from within Word vba Combine Different Word files into one file and update Table of Content tejaspareek Word VBA 4 11-04-2014 05:50 AM
Auto update image in a PowerPoint file expert4knowledge PowerPoint 0 05-28-2012 06:04 PM
Update .accdb file from within Word vba mdb/accdb, missing tables & queries Peter J. Veger Mail Merge 1 02-23-2012 10:42 PM
Update .accdb file from within Word vba How to update automatically the “file name” as we do for the “Date”? Jamal NUMAN Word 2 01-06-2011 02:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft