Fill a Word document from Access and protect it

J

Joop

Hi All,

I have build a correspondence management system in Access. From the Access
VBA app a document is opend in Word with the right template and on a number
of bookmarks data from Access is filled-in so all the user has to do is
write the letter.

My question:

Is there a way I can protect the data, that was entered from Access, from
editing by the user (lock it)

So far I can't find a way in the Word object model, I have tried Formields
and looked at using subforms but I haven't found the answer yet

Any Ideas?
 
A

Al Borges MD

Hi Joop:

You can never fully keep a hacker out of Access, but with the right tweeks
you can keep 98% of folks out. You could do the following:

1) Hide the access tables altogether, especially if you have Word getting
the data from Access rather than vice versa. In Word you can use the VBA
environment to do this. In fact, you can even bring up stuff from an Access
table without even opening up Access. Example, the following code needs
Access open:

DoCmd.RunSql "SELECT Medications.* FROM Medications WHERE MEDICATIONS.ACCT =
" & [ACCT] & " ORDER BY Medications.ACCT;"

But the following doesn't:

Set db = OpenDatabase(conDBpath)
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT Medications.* FROM Medications WHERE
MEDICATIONS.X = -1 ORDER BY Medications.md1;")
' Determine the number of retrieved records
On Error Resume Next
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = .Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = .GetRows(NoOfRecords)
' Cleanup
.Close
db.Close
End With
tt = "0 in"
uu = "0 in"
vv = "1.2 in"
ww = "1.4 in"
XXX = "0 in"
yy = "0.6 in"
zz = "0.6 in"
aa = "3.8 in"
ListBox1.ColumnWidths = tt & ";" & uu & ";" & vv & ";" & ww & ";" & XXX
& ";" & yy & ";" & zz
ListBox1.ListWidth = aa

In Access you can place the following code into your startup module:

'If DATE > #12/1/2004# Then ' I can use this to make my application
time controlled.
'Application.Quit acQuitSaveAll
'End If
'ChangeProperty "StartupShowDBWindow", dbBoolean, False
'ChangeProperty "StartupShowStatusBar", dbBoolean, False
'ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
'ChangeProperty "AllowFullMenus", dbBoolean, True
'ChangeProperty "AllowBreakIntoCode", dbBoolean, False
'ChangeProperty "AllowSpecialKeys", dbBoolean, True
'ChangeProperty "AllowBypassKey", dbBoolean, False
ChangeProperty "confirmrecordchanges", dbBoolean, False
ChangeProperty "confirmdocumentdeletions", dbBoolean, False
ChangeProperty "confirmactionqueries", dbBoolean, False
Call MultiAccess.winCheckMultipleInstances(False)
AddAppProperty "AppTitle", dbText, "Zfile Medical Database System"
Application.RefreshTitleBar
'Application.SetOption tobreakonerrors, 2
Exit Sub

(note that I have placed a single quote mark before most lines- if you get
rid of these, you'll never be able to see your stuff again... so be careful
and make backups!)

If you need further help with any of these 2 methods, ask for further
detailed followup..

Regards,
Al
 

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