Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Adding A Hyperlink To A Field Using VBA


Hi everyone. I'm trying to link to a file with a hyperlink. It's the only way I can think to do this. we currently get faxes sent to our desktop. I need to be able to double click my attachment field, pick my file, have it asign a unique name to the file, move it to my attachment folder, and then insert a hyperlink in the text box. I've managed to do everything except get the hyperlink to work. It puts the full path to my new file in the text box, but it doesn't do anything when I click on it. It looks like a hyperlink, but doens't act like one. Here is the code I have so far:


Code:
Private Sub Attachment_DblClick(Cancel As Integer)

Dim fs As Object
Dim dlgOpen As FileDialog
Dim vrtSelectedItem As Variant
Dim myDir As String
Dim OldName, NewName
Dim myString As String
Dim SourceFile, DestinationFile
Dim strFileName As String

myString = Format(Now(), "yyyymmddhms")

Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
Set fs = CreateObject("Scripting.FileSystemObject")

With dlgOpen
.AllowMultiSelect = False
.Show

For Each vrtSelectedItem In .SelectedItems
myDir = vrtSelectedItem
Next vrtSelectedItem

End With

strFileName = Right(myDir, Len(myDir) - InStrRev(myDir, "", -1))

myEnd = Right(myDir, 4)

fs.CopyFile myDir, CurrentProject.Path & "Attachments"

OldName = CurrentProject.Path & "Attachments" & strFileName: NewName = CurrentProject.Path & "Attachments" & myString & myEnd

Name OldName As NewName

Me.Attachment.Value = NewName

End Sub
I've set the field type to Hyperlink. Can anyone tell me either a better way to link to a document, or how to use the value in the cell as a hyperlink?

Thanks for any help!

Dave

P.S. Forgot to mention, I'm using Access 2002 (XP)




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
String In Hyperlink Field
I want to put the address of a hyperlink as a string into the hyperlink field; the string is there, but the connection does not work, when I click on it. What is wrong? Found the solution!

Define A Certain Field As Hyperlink
Hi Friends,

I'm using an Access 2000 db which have a field called "Rem" set as Hyperlink type.
I'm also using an ADODC and a simple data grid for showing the records.
1. Is there any way for showing this field on datagrid as hyperlink?
2. Same question for datareport...
Hope I was clear enough.
Thanks for your help
Yoav

Inserting Text Into Hyperlink Field
Hello, all,

Wondering if osmeone can help with this. here's the sceario:

I have an Access 97 database with a field called path. This field has a hyperlink data type. If I manually type a path into the field, it works great.

ie. I typed
\ServerMain est.doc

By clicking the link, it opens this document. Now, I can insert the same thing into the field from VB6 using the addnew method but for some reason, the link isn't "live" when I click it.

ie

VB Code:
rs.addnewrs!path = "\ServerMain est.doc"rs.update


This will insert the path into the field as a hyperlink, but it doesn't do anything when I click the link. Anyone know why? Am I missing something?

Thanks in advance!

Strick

Create A Field As Hyperlink In Sql Database
Is there any Datatype in sql database to create a field as Hyperlink .This is possible by using Ms-Access ...But it is not possible by using sql to chage field data type as "Hyperlink"

If u know it,,please help

Help in this regard is appreciated

How To Set Hyperlink Database Field To Textbox In Vb6.0
hai evryone,
iam suresh from bangalore.
iam creating an application in that i've connected to the database. in my
database there is a hyperlink field.
that hyperlink field is link to the doc file , its working fine in
the database. when its came to vb textbox its not working.

what i have to do in that textbox? or that database field?
if i use richtextbox also not worhking.
or
is there any other control to navigate to doc file in vb?

can you anyone send solution for it.



Thank you.

How To Set Hyperlink Database Field To Textbox In Vb6.0
HiYou can use a webrowser control and use the code aswebbrowser1.navigate2 email@removed wrotehai evryone,iam suresh from bangalore.iam creating an application in that i've connected to the database. in mydatabase there is a hyperlink field.that hyperlink field is link to the doc file , its working fine inthe database. when its came to vb textbox its not working.what i have to do in that textbox? or that database field?if i use richtextbox also not worhking.oris there any other control to navigate to doc file in vb?can you anyone send solution for it.Thank you.

Adding Hyperlink
I have a string variable the I am using to put text into a cell in a word table.
The text which makes up the string is a list of Documents or URL addresses. I need to make each individual item in the string into a hyperlink.
The string would look similar to this:

D:Business_Need_Definition.doc
www.msn.co.uk

The variable is called dtext.
I have tried this code for each item in the list as I build the string
dtext = "<a href="" & dtext & "">" & dtext & "</a>"

But it does not insert correctly I get it displayed as

<a href=" & dtext & "></a>
D:Business_Need_Definition.doc

Any ideas on how this could be done?

Adding A URL Hyperlink
Thank you very much to Paul for replying. But I couldn't figure out where to put the first line of code that you gave me:

In a module (.bas) put the following API declaration for ShellExecute (causes apps to fire according to extensions):


Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

I'm only taking a beginner's course in VB so pretend you're talking to a kindergartener )
Where does the Declare Function part of the code go? I get an error everywhere I put it.

Thanks a lot! I really appreciate any responses!

Adding Hyperlink
Can i add hyperlink to text and buttons?

How To Creating Hyperlink In Crystal Reports On A Field
Hi everybody,

I have a problem regarding crystal report i have to tables tblMailInfo and tblAttachments.
I have designed a main report selecting fields from tblMailInfo, the problem is that i want to create a hyperlink
on the MailID field so that when i click this field a new report opens displaying the attachements for that MailID from tblAttachments
Please help me in this problem with code if any one have.

Hyperlink From A Cross-tab Field Does Not Work At Runtime
Hello,

Could anyone tell me why the hyperlink from a cross-tab field does not work at runtime. I encounterd this problem in both CR 8.0 and CR 8.5 releases.

Best regards,
Florin

URGENT Adding Url Hyperlink
How do you add a URL hpyerlink to a visual basic project form? Can you give me an example of code??

Adding A Hyperlink To A Messagebox
How do I add a hyperlink to a message box? such as a weblink?
Thanks.
- Gabe

How To Edit A Hyperlink Field In Access Database With A VB6 Application
Hi,

how do I edit a hyperlink field in an MS Access database from within a Visual Basic 6 application?
The Data Type of the column in the database table is already Hyperlink.
(I can edit, save, load an Access database with my VB6 application, but now I want to add hyperlinks. Can't figure this one out.)

Thanks in advance.

Adding A Hyperlink To A Standard Form
Can someone please tell me the easiest way to add a hyperlink to a standard form.

Adding Hyperlink Capability To RichText Boxes
How would this be done??? I really would like to be able to use this.

Thx a bunch

Messup000

Adding Hyperlink Capability To Rich Text Boxes
I've looked but come up dry. Where do I find the tips?

Adding Two Field's Data Ino One Field
hello

The following SQL command adds two fields data into one field.

tbl1 structure:
_____________________________
field1 field2

a1 b1
a2 b2
a3 b3
a4 b4
____________________________

Select field1,field2 as fieldNew from tbl1;

the result is :

___________________________
fieldNew

a1b1
a2b2
a3b3
a4b4

__________________________


But I want to get:


_________________________

fieldNew

a1
a2
a3
a4
b1
b2
b3
b4


________________________



Please anyone help me to solve this problem.


Thank you all.

Bye...

Adding Two Field's Data Into One Field Using SQL.
Hello...

Can anyone tell me how can I Get two different field's data into one (newly named) Field using SQL?or VB?

Adding A Field On The Fly
Is there a way to add a field to a database table through code in ADO?
thanks very much, ted

Adding A Field
I am trying to add a field to a DB, with SQL. Is this possible? Where should I look?

Adding A New Field.
Alright,
well I am making a database system for some people, and ive completed a good chunk of it.

now i just reliazed i needed to add another field in the database base.

Say i have Name, ID,Email. i need to add "address"/
now I use SQL statements to work with my database as i find that the easier, and i know ill have to rewrite all the my sql statements.

but for the future, how can i prevent this? as in if a new field is added then the sql statements are already updated.


especially for the insert statement.

Adding A Field To My Table
i am using this to make a table and fields in my database

Set db = OpenDatabase("C:WINDOWSSYSTEMDailyacivity.mdb")
Set tb = New TableDef
Set f = New Field
f.Name = "Date"
f.Type = dbDate
f.Name = "Shift"
f.Type = dbText
tb.Name = intpress
tb.Fields.Append f
db.TableDefs.Append tb

it makes the table but only one of the fields the shift field how can i add more fields?

Adding A New Field To A Table
Is it possible to add a new field to an existing table throught a SQL statement?
I've searched the forum but I did not find anything, can anyone help me?

Adding Field With ADOX
I'm trying to add a field to a table using ADOX. Adding the field is easy but I can't figure out how to set its default value. What should I add to the following code?

Dim oCat As ADOX.Catalog
Dim oTable As ADOX.Table
Dim oColumn As ADOX.Column

Set oCat = New ADOX.Catalog

oCat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _
"Data Source= MyDatabase.mdb;"
Set oTable = oCat.Tables("MyTable")
Set oColumn = New ADOX.Column
With oColumn
.Name = "NewField"
.Type = adUnsignedTinyInt
End With

oTable.Columns.Append oColumn

Set oColumn = Nothing
Set oTable = Nothing
Set oCat = Nothing

Thanks!

Adding Field To Db Programmatically
I need to be able to programatically add a field of type text with a length of 70 to a database in ADO. If I can do this through code it will save me a very long and unnecessary trip.

thanks, Ted

Adding A New 'field' To The Database
I can't seem to figure out a easy way to add a field to a database.. This is what I'm trying.

Private Sub AddDetailDBFields(sFileName As String)
Dim adoRS_DetailFields As ADODB.Recordset

'Assume Connection Open to adoConn_SQLDB_Local

'Open Recordset
Set adoRS_DetailFields = New ADODB.Recordset
adoRS_DetailFields.Open "Detail", adoConn_SQLDB_Local

adoRS_DetailFields.Fields.Append "New Field Name", adDouble

adoRS_DetailFields.Close
End Sub

All I'm trying to do is add a new Field to a Database Table.
Thanks for the help.

Adding New Field In To Access
Hi All

We have a VB program which was written originally in VB5 and then we upgraded to VB6. Our original database was designed a few years ago in Access version 2. It only contains 5 fields. We use a data control to link to our Access file.

My question is:

Through our program is it possible to extend this to 6 fields by using a command code to insert another field which can also be incorporated in the program being already used?

The reason I ask this is that among the people that use the program, some have Access on and some do not.

Any help would be appreciated.

Thanks

Steve

Problem Adding DAO Field
i'm trying to append new field on existing database table but my code not working here's my current code using DAO:


Code:
Sub AddField()
Dim tblObjectTracking As TableDef
Dim AddField As Field
Dim X As Integer
Dim Fld As Field
On Error Resume Next
Set db = OpenDatabase("logfile.mdb", False, False, ";pwd=pass")
Set tblObjectTracking = db.TableDefs("log")
Set Fld = tblObjectTracking.CreateField("OT", dbText, 250)
With Fld
.AllowZeroLength = True
End With
With tblObjectTracking.Fields
.Append Fld
.Refresh
End With
With tblObjectTracking.Fields
.Append Fld
.Refresh
End With
db.TableDefs.Append tblObjectTracking
db.Close: Set db = Nothing
Set tblObjectTracking = Nothing
End Sub
anyone can help... thanksss
Edit by Moderator:
Posting a thread in a discussion forum is a pretty good indication that you require help, so no need to put that in your thread title.

Adding Data To A New Field
Hi,

I have used the following code to add a new field to a database. Is there a way to stop this field having a Null value but still keep it empty?


Code:


strSQL = "SELECT * FROM cells ORDER BY cell, Proof;"
Set db = OpenDatabase(lblDatabase.Caption, False, False)


Set tbl = db.TableDefs("cells")

' Create and append new Field objects
tbl.Fields.Append tbl.CreateField("Extra", dbText, 20)

Adding Together One Field In All Records.
In my database their is one field that has the revenue for one item how would i add together each of them to get a total revenue?

I also want to be able to delete one field in different records e.g. delete the revenue for each item how would i go about doing that?

Thanks for your help

Adding New Field To Table Through SQL
I have been asked to write a piece of SQL to add a new field to an existing table (SQL Server).

I haven't got a clue how to do it!

Can anyone help me?

Adding 2 Field Primary Key Using DAO
One last question...I want to define 2 fields as the primary key in a Jet database using DAO. I understand how to create an index on a single field using createindex but I am having problems setting 2 fields as a primary key. Any help would be greatly appreciated. Thanks in advance!!

Adding Field To Table On Import
How can I add a field to a table as I loop through and import a months worth of Excel Info. The field will contain the date (120103) using a string to identify the data.
the code is below. the command15_click() works fine. Its the addfield2() code where I get an error message. RunTIme error "3421" Data type conversion. any ideas would be helpful
for example: I need the first field to be:
120103 data...data..data
120203 data..data...data

Right now I only have data.

Code:
Private Sub command15_click()
Dim strname As String
Dim stryear As String
Dim itimer As String
Dim filestr As String
itimer = 31
strname = "I:Socc
eportsDailyLog_"
stryear = Combo23
filestr = Combo18 & Combo23
Call CLEAR_LOAD

Do While (itimer > 0)
strpath = strname & Me.Combo18 & Format$(itimer, "00") & stryear
DoCmd.TransferSpreadsheet acImport, 8, filestr, strpath, False, "C55:AA55"

Call addfield2

itimer = itimer - 1
Loop
MsgBox "FINISHED"

Sub addfield2()
filestr = Combo18 & Combo23
Set dbs = CurrentDb
Set tdf = dbs.TableDefs!(filestr)
' Create new field in table.
Set fld = tdf.CreateField(filestr, Number, 11)
fld.OrdinalPosition = 1
With TDef
.Fields.Append .CreateField("TextField9", dbText)
.Fields.Append .CreateField("IntegerField10", dbInteger)

End With
Set dbs = Nothing
End Sub

Adding One Or More Lines In A Memo Field
is there a fuction I can use to add lines in a memo field using VBA??

Adding A Field To An Access Table
Greetings,
On a particular user action, I would like to add a new field to an Access table. Is there a dynamic way to do so. ( kinda like when we are creating a table at Design time...)
Thanx

Adding A Field To The Begining Of A Recordset
Is there anyway of adding a field to the beginning of a ADODB recordset which is already populated? I would rather not changed the stored procedure which creates the recordset or have to create a new stored procedure. I don't think rs.Fields.Append can do this, can it?

Cheers

G

Getting Field Names And Adding To Lstbox
I am using the following code to try and get the name of the columns in my access database and am having no luck. Basically I want to add the names of all the columns to a listbox in the order they appear in the database:


Code:
Set ElementConn = New ADODB.Connection
Set ElementRecSet = New ADODB.Recordset

ElementConn.CursorLocation = adUseClient
ElementConn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "Periodic Table.mdb;"
ElementConn.Open

Set ElementRecSet = ElementConn.Execute("SELECT * FROM Table2 ORDER BY AtomicNumber")

Dim i As Long

For i = 1 To ElementRecSet.Fields.Count
lstline1.AddItem ElementRecSet.Fields(i).Name
lstline2.AddItem ElementRecSet.Fields.Item(i).Name
lstline3.AddItem ElementRecSet.Fields.Item(i).Name
Next i

ElementConn.Close
I get an error at the red line (Runtime error 3265) "Item could not be found in the collection corresponding to the requested name or ordinal"

Any ideas?

Thanx

Adding Field To Index (on-the-fly) In Access Using DAO
So, I'm trying to change / "upgrade" the structure of an access database using (for reasons that are too long to go into now) DAO

I've stored all the "relevant" info in a custom file structure, and I'm then comparing that with the structure of the DB.

Adding New tables, fields, indexes works fine...

But when I try to add a newly created field to the Primary Index using something like this

Code:
Set td = db.Tabledefs(TableName)
Set id = td.indexes(IndexName)
id.Fields.Append td.Fields(FieldName)
I get Error 3367 - Can't append. An object with that name already exists in the collection.
But it doesn't / can't already exist because I only just created the field.. I've checked the Fields collection of the index and the field I'm trying to add definitely isn't there.

So I tried it a different way....
First Delete the index...
Then Recreate the entire index..
This gives me exactly the same error when I try to add the first field (which is not the new field) to the index... but at that point the id.fields.count = 0, I just created the index object, so it's empty....

So I'm guessing that the error is occuring for a reason other than the VB Help "stated" reason.... does anyone have any idea what else could cause this error?

Adding Nullable Field To Recordset?
hi all,

i have a recordset that I create in code. trouble is one of my fields needs to be able to be blank, but i get a

"canoot set non nullable field to null" error.

here's my recordset creating code:

sfsRS.ActiveConnection = Nothing

With sfsRS.Fields
.Append "Item_No", adBigInt
.Append "Description", adBSTR
.Append "Seq", adInteger
.Append "Cases Per Hour", adInteger
.Append "Qty", adDouble
.Append "Load (Hours)", adDouble
.Append "SHIP_DATE", adBSTR
.Append "SHIP_TIME", adBSTR
.Append "Comments", adBSTR
End With

the field i need to have allowed nulls is "Seq".

Adding Field Names To A Table
I have the following code which adds fields to a table. The problem is that some of the fields will end up having spaces in the names. This creates a problem because then vb assumes that the second word in the name is actually the variable type definition.
How do i get around this?

myConnect.Execute "ALTER TABLE Mark_Test ADD COLUMN " & SelMag(l) & " text;"

Adding A Calculated Field To A Datagrid...
Hi,

i asked this quastion once and no one answered me...
I have a function Age() on my module, it gets a date and calculates the age of this person with this date of birth...
I have a players table and when i put it in a datagrid i want to add another column which will use the players' date of birth and calculate this persons age, using the function on my module...

how can i do it?

please help... thanks a lot.

Adding Data To Database Field
Hi there,

I'm not sure at all how to do this so assistance will be much appreciated! I need to add a quantity amount (txtQuantity) to the field "Quantity" in my "CurrentStock" database. But it has to add to the value that is already in that field. Also if the txtProduct is "Laptop" then this amount needs to be added to the record 'Laptop' quantity. (i hope this makes sense!?) Heres my attempted code:


VBCODE Code:
Private Sub cmdUpdate_Click()
'When button is clicked, it will check input from check box and msgbox then update'
If Check1.Value = vbChecked Then
    OrderMsgBox = MsgBox("Please confirm that this order has been completed", vbExclamation + vbYesNo)
'If box is ticked and yes is clicked it will update the "completed" field'
If (Check1.Value = vbChecked) And (OrderMsgBox = vbYes) Then
    UpdateCompleted
    Unload Me
    UpdateStock1.Show
End If
End If
End Sub

Private Function UpdateCompleted()
'With condition to edit and update the completed field in the order table'
With datOrder.Recordset
.Edit
        .Fields("Completed") = Check1.Value
       
.Update

[color="Red"]If txtProduct.Text = "Laptop" Then
Add txtQuantity.Text[/color] (stuck here!)

End Function

Adding Database Field Attributes
From VB I have loaded up a .mdb file
I was just wondering how can I edit the field attributes

e.g.
The Description attribute
the Validation rule
default value etc..

Also, is there a good place to look to show how I can import values from an excel spreadsheet into my VB program!

Thanks

Adding A Combo Box To One Of The Field Of A DBgrid
frnds
Let me know is thre any method to add a combo box to one of the field of a
dbgrid??
thanks for any help

Adding Text To Listview Field?
Hi all.

I have a program that has about 7 text fields and I have one listview. I have an add button for adding a new contact, like an address book program, that will add all text fields respectively to the listview fields. Instead of using a database this time I'm using a dat file to store the listview saved information from the textfields. So far I have this:

Code:
'I know this doesn't look right
Private Sub cmdAddNew_Click()
Dim xItem As ListView
Dim intList As Integer

lstContacts.ListItems.Clear

For intList = 1 To lstContacts.ListItems(intList).ListSubItems
  If lstContacts.ListItems(intList).ListSubItems > 0 Then
    With lstContacts.ListItems(intList).ListSubItems
    .Add intList, , txtID.Text
    .Add intList, , txtFirstName.Text
    End With
  End If
Next intList

End Sub
------------------------------------------------------------------------------
Private Sub cmdListAll_Click()
Dim xItem As ListItem

lstContacts.ListItems.Clear

Open App.Path & "Contacts.dat" For Binary As #1
Get #1, , cUser
Close #1

With cUser 'cUser is in a module as a public type
  txtID = .Contact_ID
  txtFirstName = .Contact_FirstName
  txtLastName = .Contact_LastName
  txtAge = .Contact_Age
  txtEmail = .Contact_Email
  txtPhoneNumber = .Contact_Telephone
  txtAddress = .Contact_Address
  txtLocation = .Contact_Location
  txtComments = .Contact_Comments
End With

Set xItem = lstContacts.ListItems.Add(, "ID", txtID, , 1)
xItem.SubItems(1) = txtFirstName
xItem.SubItems(2) = txtLastName
xItem.SubItems(3) = txtAge
xItem.SubItems(4) = txtEmail
xItem.SubItems(5) = txtPhoneNumber
xItem.SubItems(6) = txtAddress
xItem.SubItems(7) = txtLocation
xItem.SubItems(8) = txtComments

End Sub


I did get somethiing back from it but it looked like the "ID" text, not the ID number in the id section, and in another case 0's in the text fields that hold strings, lol. At least my machine is still running.

If anyone would know how close or far off I may be that would be great. Thanks for all your time.

RJ

Adding Record With Autonumber Field In SQL
Im adding new record in my SQL table with an autonumber field, but when i use the rs.update method it says that recid is null. Recid is the autonumber field in my table. Isnt it should be automatically generated and you dont need to put values in it? What is the reason for that error?

Thanks

Adding Hidden Field To Combo Box.
Is it possible (I thought it was) to add a hidden field to a combo box, i.e I want to have Text in the combo box that the user sees etc..but when it selects something then I want to use internally in code the ID that is attached to the text since my Design of my database is:

ID: Some number
Name: Name of Item

so is this possible? if so how? i suspect i need something different from cboBox.AddItem since the Item is just a string text field (what i would use for name) any help on how to add this hidden field of ID's and retrieve them later would be greatly appreciated thanks!

Adding A Yes/No Field To An Existing Table Using DAO.
Hi,
Do anyone know how to add a Yes/No field to an existing table using DAO?
(MS Access)

Copyright © 2005-08 www.BigResource.com, All rights reserved