954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help---urgent!!

Is it possible to open a hyperlink and display the data in a label or text box?

I have a table in Access where the data type of a record is a hyperlink. I would like to open that hyperlink and display the data in a label or text box.

It is for a school project and so quick responses would really be appreciated. I'm also sorry as this is my second thread on the matter, but no one replied to the last thread. Hopefully you can understand the urgency.

Thank you
Daniel.

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Hi Daniel,

When you mean data do you mean the webpage itself? If you want a webpage to be displayed within VB follow the instructions of this link:
http://www.trap17.com/index.php/how-make-web-browser_t31604.html

Don Gino
Junior Poster
102 posts since Oct 2006
Reputation Points: 16
Solved Threads: 2
 

no. its actually a text file.
hmmm...its hard to explain!
the user inputs the directory they would like to save the text file, the program saves that directory in access as a hyperlink. then, the user can access the file through the hyperlink?
..is it possible?!

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

s. u can use the file system object and textstream to open a textfile, read the data and display it in a lable or a textbox.

Add the Microsoft Scripting Runtime in the References. Create objects of the following.
FileSystemObject and TextStream


Try out these, if u still cant make the code then 'll be there to help u out.

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

thank you soo much shaik for your time and help!...but i'm still unsure on how to open the text file from the hyperlink in my access database?....

cheers
Daniel

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Open the recordset. Extract the field with hyperlink and connect it to the File System Object and TextStream

Dim rs as New ADODB.Recordset
Dim FSO As New FileSystemObject
Dim FL As TextStream

rs.Open "SELECT hLinkField FROM MYTABLE WHERE ID = 1", con,adopenKeySet, adLockReadOnly

'If record found then
If rs.BOF = False Then
  'open the file in the field which contains
  'the hyperlink to the textfile
 Set FL=FSO.OpenTextFile(rs!hLinkField, & _
            ForReading, False)
 Text1.Text = ""
 While Not FL.AtEndOfStream
  Text1.Text = Text1.Text & FL.ReadLine
 Wend
 FL.Close
End If

Set FL = Nothing
Set FSO = Nothing


Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

Here I assume u know how to connect to your database. i have considered ADODB.Connection object "con" which is global and already attached to the database.

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

thank you shaik, i used that code but it says there is a complie error: User-defined type not defined...with
fso As New FileSystemObject highlighted

???

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Here I assume u know how to connect to your database. i have considered ADODB.Connection object "con" which is global and already attached to the database.

Regards Shaik Akthar

um...to connect my database...
Set db = OpenDatabase(App.Path & "\database.mdb")
Set rst = db.OpenRecordset("table")

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

sorry...i forgot to add the reference. but now an error message comes up saying
Run-Time error 438:
Object does not support this property or method with
rst.Open "SELECT hLinkField....." highlighted.
so, i don't know what to do!

???

cheers
Daniel

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Run-Time error 438:
Object does not support this property or method with
rst.Open "SELECT hLinkField....." highlighted.
so, i don't know what to do!


Dear Dan,

I added a dummy SQL Query stating that u have to use your fieldname which has the hyperlink and table name which holds the hyperlink column.

replace hLinkField with the fieldname in your table
replace MyTable with the tablename in your database
if any filtering is to be done based on a particular column add the 'where' clause
or just query all the records like "Select * from table"


Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 
Dim FSO As New FileSystemObject
Dim FL as TextStream

Set db = OpenDatabase(App.Path & "\database.mdb")
Set rst = db.OpenRecordset("table") 

'If record found then
If rst.BOF = False Then
  'open the file in the field which contains
  'the hyperlink to the textfile
  'here replace the hLinkField with the hyperlink field actually
  'in ur table

 Set FL=FSO.OpenTextFile(rst!hLinkField, & _
            ForReading, False)
 Text1.Text = ""
 While Not FL.AtEndOfStream
  Text1.Text = Text1.Text & FL.ReadLine
 Wend
 FL.Close
End If

Set FL = Nothing
Set FSO = Nothing

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

i tried that...am i not putting it in right?
i have...

rst.Open "SELECT Description From Equipment, con, adopenKeySet, adLockReadOnly

how am i supposed to do it?
i've also tried rst!description.

thank you very very much for your help shaik. you are a lifesaver

Daniel

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

here in this code it reads only the first record, opens the text file specified in the hyperlink column and displays its contents in the textbox.
Also note what the name of the textbox is in your form. here i have mentioned it as Text1. See that if u too have the same name of the textbox u created or anything else u might have changed the Name property of the textbox in which u r displaying the file contents.

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

u have not closed the quotation marks dear

rst.Open "SELECT Description From Equipment", con, adopenKeySet, adLockReadOnly


Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

i still can't seem to get it to work...i have tried soo many different ways!

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

u have not closed the quotation marks dear

rst.Open "SELECT Description From Equipment", con, adopenKeySet, adLockReadOnly

Regards Shaik Akthar

i have exactly that, but the same error message appears!

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

PLZ POST THE ENTIRE CODE. I'LL JUST CORRECT IT OUT IF ANY MISTAKES.
ALSO UPLOAD THE DATABASE IF U CAN IN ZIP FORMAT.

Regards
Shaik Akthar

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

HEY con is the database object i referenced.
i think u have to use 'db'

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

unfortunately, i cant upload the database because the computer i am programming on does not have internet and i am using a seperate computer for this.

i tried db instead of con....still the same error message!

i'm sorry about the fuss, but i really can't thank you enough for all the help you have given me.

thank you
Daniel

iamdaniel123
Newbie Poster
15 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You