adding an attachment and view a file in a form

fastmike

Registered User.
Local time
Today, 06:24
Joined
Jun 9, 2006
Messages
61
hi all. i am creating a form by the name of ISSUES. i will have a field by the name of ISSUE# where user will be able to type the issue#. i was wondering if it is possible for the user to add an attachment of the issue file. in other ways to make it easier i am asking if it is possible to attach a file in a form and to view it also. any help will be really great.
Thanks
 
thanks for the reply rural guy. i guess i wil change my field name to ISSUE rather than issue# i know access have issues about that characters. The link you posted (Call the standard Windows File Open/Save dialog box) have a VB procedure so what i need to do is create an event procedure and copy the code of the link you posted. i hope i am rite. i will go to my work and try to implement it tomorrow. please do check this post also tomorrow if i am able to do it. second and last i will be having reports in my database. i was wondering if it is possible to just view certain part of the reports rather than viewing the whole thing for eg i have fields (issue, resolve date, short desc, long desc, etc) what if i just want the reports to be viewed with (issue, short description only) is it possible?
 
Last edited:
The link I posted needs to be copied into a *standard* module and then it can be invoked from anywhere. I suspect everything you want to achieve can be accomplished but without more details it is difficult to provide any further solutions. Post back when you have more details or additional questions and we will attemt to answer them.
 
Last edited:
I have a button by the name of (Add a file) in the form. i copied this code in a standard module:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

when i try to run it or run it. it gives me an error msg on StrFilter. anyone can explain y?. just wanted a user to add a file in the form for each specific record without going in design view .
 
Last edited:
Start by putting this in the code for your button and see what happens. This goes in your module for the form.
'-- Browse for the source file(s)
Me.ControlName = GetOpenFile(CurrentProject.Path, "Select Source File")


Using your ControlName of course.
 
thanks for replying RG. i have a button by the name of AddaFile. here is what i have typed in my module

Me.AddaFile = GetOpenFile(db2.Path, "Select Source File")
Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

it is still giving me error saying(outside procedure) at db2. my current project name.
 
Comment out everything but this modified line and let me know what happens. What name did you give the Standard module?
Me.AddaFile = GetOpenFile(CurrentProject.Path, "Select Source File")
 
No, wait a minute. You can't assign a value to a CommandButton. Change your code to:
MsgBox "You have selected [" & GetOpenFile(CurrentProject.Path, "Select Source File") & "]"
 
Good name for the module. What was the results of the test?
 
Option Compare Database
MsgBox "You have selected [" & GetOpenFile(CurrentProject.Path, "Select Source File") & "]"

Invalid outside procedure error.
 
You need to select the AddaFile Command Button and right click on it. Go down to properties and left click. Select the Event tab and press the "..." button on the OnClick line and select build code. Put the code I supplied inside of that sub routine and save and Debug>Compile. If it compiles ok then run the form and press the button and see what happens.
 
hey RG thanks for helping me out. i am at my home now but before that i was also thinking the same thing that to put that code in ONclick event.

MsgBox "You have selected [" & GetOpenFile(CurrentProject.Path, "Select Source File") & "]"

when i try to Compile it it gives me an error msg again. i will do it one more time tomorrow and thanks alot for answering my questions and helping me out. i will keep you updated.
 
RG i tried your code in ONclick it gives me an error on this word "GetOpenFile" and the msg is "Outside procedure".
 
Your code module should look something like this:
Code:
Option Compare Database
Option Explicit

Private Sub AddaFile_Click()

MsgBox "You have selected [" & GetOpenFile(CurrentProject.Path, "Select Source File") & "]"
  
End Sub
Did you delete all of the other stuff that didn't work?
 
At least that error is more like it. Now we need to examine Module1. Did you copy everything from
'***************** Code Start **************
to...
'************** Code End ******************
from that link into your Module1?
How about posting to top 10 lines of that module here so I can see it.
 
Module1
********************************
Option Compare Database
Option Explicit


Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

End Sub


Onclick Event
****************************
Option Compare Database
Option Explicit

Private Sub AddaFile_Click()

MsgBox "You have selected [" & GetOpenFile(CurrentProject.Path, "Select Source File") & "]"

End Sub


This is what i have till now
 
Last edited:

Users who are viewing this thread

Back
Top Bottom