By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,183 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,183 IT Pros & Developers. It's quick & easy.

Access database with a Word-attachment...

P: 4
Hi,

I am hoping someone can help me.

I have build a database in Access but have only one thing that I can't do. Its a database for work which contains both personal and work-related info.

I need to attach a Word doc to every employee entered in the database. Only problem is, for every employee it has to be a different document.

Also there has to be a button with which the person filling the database can search for the right document and add that without any trouble.

Then there has to be a button for the person looking at the information in the database to either put in another document (if necessary), and open the word document and alter that.

Does anyone know if this is possible and if so, how do I do this?

Annemarie
Feb 1 '07 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,692
Hi,

I am hoping someone can help me.

I have build a database in Access but have only one thing that I can't do. Its a database for work which contains both personal and work-related info.

I need to attach a Word doc to every employee entered in the database. Only problem is, for every employee it has to be a different document.

Also there has to be a button with which the person filling the database can search for the right document and add that without any trouble.

Then there has to be a button for the person looking at the information in the database to either put in another document (if necessary), and open the word document and alter that.
Does anyone know if this is possible and if so, how do I do this?

Annemarie
How about a button that opens a standard Office File Dialog Box from which you can select a file and store its Absolute Path internally then another button that will actually Open the File for Viewing/Editing if so desired. If this is what you are requesting, let me know and I'll start work on the coding. It may, however, be a little involved. The other option would be to store the actual Word Documents in an OLE Object Field which would initiate its own set of problems given what you would like to achieve.
Feb 1 '07 #2

P: 4
How about a button that opens a standard Office File Dialog Box from which you can select a file and store its Absolute Path internally then another button that will actually Open the File for Viewing/Editing if so desired. If this is what you are requesting, let me know and I'll start work on the coding. It may, however, be a little involved. The other option would be to store the actual Word Documents in an OLE Object Field which would initiate its own set of problems given what you would like to achieve.
This is exactly what I want :) One button for the one filling in the database and one for the one viewing the database.

If you could find the coding for me I would be most grateful.

Annemarie
Feb 5 '07 #3

P: 13
Hi,

I am hoping someone can help me.

I have build a database in Access but have only one thing that I can't do. Its a database for work which contains both personal and work-related info.

I need to attach a Word doc to every employee entered in the database. Only problem is, for every employee it has to be a different document.

Also there has to be a button with which the person filling the database can search for the right document and add that without any trouble.

Then there has to be a button for the person looking at the information in the database to either put in another document (if necessary), and open the word document and alter that.

Does anyone know if this is possible and if so, how do I do this?

Annemarie
I have done this in VB, but I am sure this would work the same in MS Access no matter what the version.

1) In your table, create a new field as Text with 255 length as maximum or to your desired len if you are sure. This field would contain the path for the MS Word document field.

2) Create a button that once pressed will ask you to input the path and filename of the Word document

3) Another button that will launch the MS Word application program with the path and filename as its parameter

This is one of the method. If this is what I understand to your problem, let me know, I may have additional method to do it.

So everytime a new person is displayed on screen, you can specify, modify or call MS Word application to open up a given path and filename of the document.

Regards.
Feb 6 '07 #4

ADezii
Expert 5K+
P: 8,692
This is exactly what I want :) One button for the one filling in the database and one for the one viewing the database.

If you could find the coding for me I would be most grateful.

Annemarie
Expand|Select|Wrap|Line Numbers
  1. 'Must set a Reference to the Microsoft Office XX.X Object Library and
  2. 'must be working with at least Access 2002
  3.  
  4. 'Set up the File Dialog Box
  5. With Application.FileDialog(msoFileDialogFilePicker)
  6.   With .Filters
  7.     .Clear
  8.     .Add "Word Documents", "*.doc"
  9.   End With
  10.    .AllowMultiSelect = False    'only 1 File allowed to be selected
  11.    .Title = "Select a Document For Form Entry"  'can change
  12.    .ButtonName = "Open Document"                'can change
  13.    .InitFileName = vbNullString                 'can change
  14.    .InitialView = msoFileDialogViewDetails      'can change
  15.  
  16.      'if the Show Method returns True, the User selected a File
  17.      If .Show = True Then
  18.        For Each varFile In .SelectedItems
  19.          Me![txtDocument] = varFile     'place the Absolute Path of the selected fileinto the [txtDocument]
  20.                                         'Field. Set its Control Source to a Field [TEXT] in the underlying
  21.                                         'Table
  22.        Next
  23.      Else
  24.        MsgBox "No Document was selected", vbExclamation, "No File Found"
  25.      End If
  26. End With
Decided to go the simple route rather than the more complex one. In the Click() Event of a button named Load Document next to you Document Field (let's say [txtDocument], place the following code. Once you have entered Documents into the Database, and you have successfully opened them, this Field should be locked for obvious reasons.
Expand|Select|Wrap|Line Numbers
  1. Dim varRet As Variant
  2.  
  3. 'If there is no value in the the [txtDocument] Field
  4. If IsNull(Me![txtDocument]) Then
  5.   MsgBox "There is no Document to Load", vbExclamation, "No Document Listed"
  6.     Exit Sub
  7. End If
  8.  
  9. Does the File and Path stored in the Database actually exist on the Local/Network Drive?
  10. If Dir$(Me![txtDocument]) <> "" Then    'File does physically exist
  11.   'Default location of the Microsoft Word executable, change if necessary
  12.   varRet = Shell("C:\Program Files\Microsoft Office\Office\winword.exe " & Chr(34) & Me![txtDocument] & Chr(34), vbMaximizedFocus)
  13. Else    'File does not physically exist
  14.   MsgBox Me![txtDocument] & " does not exist in the specified Directory", vbCritical, "File Not Found"
  15. End If
Feb 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.