browsing and opening the file from the access table

S

sadat

Hi.

This site is a very good source to learn office applications. Now I have a
problem. In the access I made a form (MasterTable) and a table (Master
Table). The objective of the form is to select any file from the harddisk
using browse button and populate the table with the full address so that when
I click the address, the file opens. I made Browse button using the code from
this site: http://www.mvps.org/access/api/api0001.htm. I made the address
column in the table to hyperlink to open the file. But here the problem lies.
When I click in the hyperlink, the file does not open. Every other thing
works fine.

However I noticed that if I add a "#" manually in the table the link opens.
But manually inputting "#" in every field is time consuming. What should I do
to make this link work. Please help. I am stuck here for days.

Thanking you in advance,
Sadat
 
D

Douglas J. Steele

Without seeing your code, it's difficult to say for certain, but if you're
currently just assigning the field the results of the call to
ahtCommonFileOpenSave, try setting it to "#" & ahtCommonFileOpenSave(...) &
"#"
 
S

sadat

Thanks Douglas for your quick response. Sorry that I did not included the
code. The code is:

Private Sub Command30_Click()
On Error GoTo Err_Command30_Click

Dim strFIleName As String
Dim strInputFilePath As String
Dim strNewFilePath As String

strInputFilePath = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

strFIleName = Dir(strInputFilePath)
strNewFilePath = "C:\Folder\" & strFIleName

Me.Image = strNewFilePath

If Len(Dir(strNewFilePath)) > 0 Then
' file already exists
If MsgBox(strNewFilePath & " already exists." & vbCrLf & _
"Do you wish to delete it?", vbYesNo + vbQuestion) = vbYes Then
Kill strNewFilePath
End If
End If

FileCopy strInputFilePath, strNewFilePath

Exit_Command30_Click:
Exit Sub

Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click

End Sub

This code is used to open a browse window and let me choose a file. Then It
also saves the file in C:\ Folder. It also helps me to populate a table
(MasterTable) with the location of the file in hyperlink. But as I said
earlier, if I click in the hyperlink in the table, the file do not open (But
if I put a "#" in the filed manually the file opens). Can you please tell me
what I am doing wrong here?

I also changed the ahtCommonFileOpenSave to & ahtCommonFileOpenSave(...) &
"#" but it did not work and gave me an error message. What can I do? Please
help me.

Thanks and regadrs,
Sadat
 
S

sadat

Dear Douglas. I forgot to mention that this code is only for copying and
pasting the data to another folder. I bounded the text box of a form to
populate the table. But my real problem is I made the format of the address
field in the table as a hyperlink. But the hyperlink do not work. However if
I insert a "#" before each address then the hyperlink works. In your previous
post you told me how to bring a "#" infront of the address. I did so by
changing the previously posted code. and also in the code that I found from:
http://www.mvps.org/access/api/api0001.htm But then again this made my
database return an error message. Why this is happening? Would you please
help me.
 
D

Douglas J. Steele

So are you saying that

Me.Image = strNewFilePath

is how you populate the field on the form (and hence in the table)?

What happens when you try

Me.Image = "#" & strNewFilePath & "#"

Incidentally, Image isn't a good choice as a name for a field or control:
it's a reserved word. For a comprehensive list of names to avoid, see what
Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html
 
S

sadat

Thank you very much Douglas. That solved my problem. You are really a great
help.

take care,
Sadat Mainuddin
 
S

Sadat

Douglas J. Steele said:
So are you saying that

Me.Image = strNewFilePath

is how you populate the field on the form (and hence in the table)?

What happens when you try

Me.Image = "#" & strNewFilePath & "#"

Incidentally, Image isn't a good choice as a name for a field or control:
it's a reserved word. For a comprehensive list of names to avoid, see what
Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html
 

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