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




Adding Quotes Into String Field


This is probably so easy, it is embarassing. In VB I have a variable containing sort fields. It is ok for ascending order, but if the user wants descending I am having trouble adding the DESC to the end of it.
RS.Sort = Sort_Parameters & " DESC"

Sort_parameters(is selected by the user) might be ID, TagNum
so I want this .. "ID,TagNum DESC" but I don't know how to group these together. Thanks guys.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Help - How Do You Place Quotes In A String Field
I have the following code removing excess junk for my word doc, but I get an error when I have the following series of code...

1 With Selection.Find
2 .Text = "<input ="checkbox">"
3 .Replacement.Text = ""
4 .Forward = True
5 .Wrap = wdFindContinue
6 .Format = False
7 .MatchCase = False
8 .MatchWholeWord = False
9 .MatchWildcards = False
10 .MatchSoundsLike = False
11 .MatchAllWordForms = False
12 End With
13 Selection.Find.Execute Replace:=wdReplaceAll

The error comes at line 2 I am sure that it is because the quotes are inside the quotes for the Text = string.....

Can anyone help?

Thanks in advance.....

Adding Quotes To String Concatenation
I am using VB6 to concatenate two strings:


Code:
Dim FirstString as string, SecondString as string, NewString as string
Dim QuoteString as string

FistString = "Part No "
SecondString = "3N49"
NewString = FirstString & SecondString
QuoteString= """ & FirstString & SecondString & """

The result for New String is:
Part No 3N49

The result for Quote String is:
" & FirstString & SecondString & "

When I want "Part No 3N49"

How do I fix the code for QuoteStriing?

Regards,
Ray

How Do I Print Out A String That Has Double Quotes As Part Of String
Hi All,
I am attempting to build up a dos batch file in Vba, that has a series of commands to be executed, where both the path to the executable and the associated file name have spaces in them. Well, as I am sure you know, the DOS command interpreter fails when it sees C:Program files and complains that C:Program does not exist. I have figured out that enclosing all of my entities in " will do the trick, but how do I escape the " in my VBCode when building a string so that the " actually is printed out?

for example

str1 = "The box"

and I want it to print out as "The box", not The box

The print out is to an open file

Any help would be appreciated !

Thanks

Joe Finkelstine
jfinkelstine@centor.com

Removing Quotes From Database Field
I have database field have "" around the value, because it was converted from Excel. Any one have function to get rid of the "Qoutes" or SQL statement.
Thanks

Single Quotes In Table Field
My SQL statement is as below:
stSQL = "SELECT u', v' FROM Result"

I get an error when I open a recordset with this statement in VB 6.0 to access my database in Access format.
How do I include the single quotes in the fields from table "Result"?
Much appreciate if someone can help!

Adding A Quote Symbol Inside Quotes
Hi,
I'm trying to add the following string in a combobox: 24"

Combo1.AddItem "24""

Obviously it won't work.
What's the proper way to add an extra '"' character between quotes?

Adding A Line That Contains Double Quotes To An ASCII File
Good Afternoon,
I need to add a lines to a ASCII file that have " in them. Is there a way of getting these lines in there?

Here is an example:


Code:
'sFileName comes into this sub from the main procedure!
Dim FSO As New FileSystemObject
Dim TS As TextStream
Set TS = FSO.OpenTextFile(sFileName, ForAppending)
TS.WriteLine "version="1.0""


Obviously that last line doesnt work, but is there a workaround?

The file is read by another application and it requires the 1.0 to be surrounded by quotes.

Any help is extremly appreciated.

Thanks
Craig.

Quotes Around String
I'm trying to put quotes around a string for it to show up quoted.

Example:

VB Code:
Dim hWnd As LongDim test As Stringtest = "hi hello" hWnd = FindWindow(vbNullString, test)

See how I'm trying to get test to show up in FindWindow quoted like "test"? I want test to be showed like "test" and not just test. Get me?

Quotes In String
I am trying to use quotes as part of a string. How do I do this?
For example...
MsgBox("Hello")
This does not show the quotes in the message box. What if I want the quotes to appear?

String With Quotes
how do I assign a string quotes... (or just make it print quotes to the screen)... i.e.

myStr = "I want to emphasize "THIS" word"

???

SQL (Quotes In String)
Hi!

declare ThisTest varchar(10)

select ThisTest = "{}[]'"

How do I enclose the quotation mark itself in that variable which I will need to parse later on...

Thanks in advance

Quotes In String
Hi!
I want to save a string. I know that I write Dim xxxx As String and then xxxx = "blabla".
The problem is that I want a text including "" and i can't do like this:
xxxx = "bla"bla"!"
Please tell me how to do this! Should I use like a backslash, or what?

/ Erik

String And Quotes - Help
If wkStationID = 1 and DistSerb(0) = "", then the statement:

SQLString = "UPDATE StationDet2 SET " _
& "SuperS = " & DistSerb(0) & " " _
& "WHERE Station_ID = " & wkStationID(ListChoice) & ";"

returns SQLString as "UPDATE StationDet2 SET SuperS = WHERE Station_ID = 1"

and this gives me a syntax error.

How can I create SQLString that if DistSerb(0) = "", the SQLString is "UPDATE StationDet2 SET SuperS = " " WHERE Station_ID = 1" ?

Double Quotes In String Exp
I am using Vbscript in ASP...

Can anyone plz tell me how to include double quotes in the string expression??

sRef= "<A HREF=(need DBQUOT HERE)newsdetail.asp?ID="

I tried &quot; " etc.. b ut doesn't workout!!

Wisdom is knowing what to do next; virtue is doing it!!!
Regards..
KK

Double Quotes In String
Hi all,

I'm recieving a query string from a textbox which may contain a double quotes in it like: "daily newspapers".

Now in my ASP page, I need to check if the entered string contains a double quotes.. So how can I check for it.

Thanks,
zeid

String Replace Quotes
I've got a string that contains the following: "5000814-00", including the double quotes. I want to get rid of the quotes in the string. How do you contruct the replace command in this case because when you do:

VB Code:
mAcc_no = Replace(ImpArray(0), """, "")

it throws up an error.

Any ideas?

Remove Quotes From A String
Hi,

how to remove the open and closing quotes of a string? For example, an original string is "yuki". I want it to become yuki

regards,
yuki

Using InStr With Quotes In String
I've encountered something I have not done. I want to search for a string with quotes in it.

<table class="TH">

How would I use that in Instr without it thinking the quotes are ending the string value?

Know what I mean?

Thanks!

String W/double Quotes In SQL
Hi everybody.,
I've searched and searched the forum and tried different things, but still no success.

One of the fields in INSERT statement might have a double quotes, like inches.

I used a REPLACE function to convert double quotes into two single, didn't work.

Any suggestions are very appreciated, because it is driving me crazy.

Thank you in advance.

Single Quotes In SQL String
How do I code my program so that if a user enters a single quote in a string value that I have to pass as a SQL statement, there will be no ODBC error.

like "David's" ... it come back with an odbc invalid format error.


Thanks

Double Quotes In String
I need to do a sql query using a key word date as a column header

What I am trying to do is assign a value to a string that has a double quote in it.

such as strquery = " select "Date" from dates"

so strquery ends up with the value
select "date" from dates


Any input would be appreciatted.

I would not like to change my column header.

Writing String W/o Quotes
i want to write data to a file. the data is a string but a dont want vb to add the ""
what do i do??

for you reference this is my code:

Code:
Dim MyData as string
MyData = "Hello world!"

open "C:data.data" for output as #1
write #1, MyData
close


this is what i get inside the file:
"Hello world!"
this is what i want to have:
Hello world!


thanks for your help!!

String With Quotes Blues
I am Trying to write to a text file but It keeps adding quotes to my statement. It is a command and won't run with qoutes around it.

It looks like this "nbtstat -a >""c:output.txt"""
It is supposed to look like this nbtstat -a >"c:output.txt"

Here is my code.
Private Sub Command1_Click()

'Form Contains Text2, Text1, RichTextBox1, and Command1

Dim MyCommand As String
Dim ComputerName As String
Dim Test As String

'The Computer You Want Info About.
ComputerName = Text1.Text

'Strings the NBTSTAT command with the Computer Name and an Output File.
MyCommand = "nbtstat -a " & computer & " >" & Chr(34) & "c:output.txt" & Chr(34)

'Moves the Command to the Test Varible
'Then to The Text2 text box to Check Formatting
Test = MyCommand
Text2.Text = Test

'Writes the Command to a Batch File
Open "C:Command.bat" For Output As #1
Write #1, Text2.Text
Close #1

'Runs the Batch File
Shell "C:Command.bat", vbHide

'Recieves an Error Because The Batch File Contains Too Many Quotes
'And the Output File hasn't Been Created
RichTextBox1.FileName = "C:Output.txt"
End Sub

Thanks for any help
Brandon

Passing A String With Quotes
hello friends

this group is awesome and has really helped me in the past........................me back with another of my doubts.i want to pass a quoted string in a method
to be precise...........i am creating a new file with FileSytemObject and using the writeline method bu it doesnt allow me to enter any strign with quotes............is there nethign of an escape character in VB as the # symbol in SQL

looking forward to your replies

Storing A String With Double Quotes
I need to store a string with double quotes and am having a bit of trouble. For example, I want the value of variable myString to be:

Curly said to Moe, "Wise guy!"

So if I code:

myString = "Curly said to Moe, "Wise guy!""

that don't work, eh?

I've tried several combination using the ` character but can't quite get the concept.

Please??

Regards...Tom

Writing A String To A File W/o The D/quotes
Is it possible to write a string to a (text) file without the double quotes at each end? This one has me stumped!

Pass String Into Vbs With Double Quotes
Hello,

I am trying to call a vbscript that includes 1 argument which has double quotes and spaces such as:

lee "struggling" doolan

and call it like such from a dos prompt:

wscript "c: est.vbs" "lee "struggling" doolan"

Unfortunatley the vbs gets confused, ignores the double quotes and spaces, and splits the string into 3 arguments, which isn't what I want.

Any ideas would be most appreciated,

Lee

Edit: Moved from General

Including Quotes In A String Literal
I am more used to c++... i can not find a way to have this work:

"hello world"

i want this text to print out with quotes around it.

i have :

text1.text = "hello world"

but i want the quotes to print around the statement on output. Anyone know how i would get this done?

Insert String With Quotes As An Argument
Hi
This post can most likely be solved by a 5-6 letter reply as this is quite trivial if you've spent some time with VB (I assume...).
Her is a snipp of my current project:

Code:
Options Explicit
Dim delimiter as String
.
.
Private Sub Form_Load()
'set options in combo box
cmbDelimiter.AddItem "Semicolon ;", 0
cmbDelimiter.AddItem "Whitespace ", 1
cmbDelimiter.AddItem "Comma , ", 2
cmbDelimiter.AddItem "Colon : ", 3
'set default in combo box
cmbDelimiter.ListIndex = 0
End Sub
.
.
Private Sub cmbDelimiter_Change()
If cmbDelimiter.Text = "Whitespace " Then
delimiter = " "
ElseIf cmbDelimiter.Text = "Comma ," Then
delimiter = ","
ElseIf cmbDelimiter.Text = "Colon :" Then
delimiter = ":"
Else: delimiter = ";"
End Sub
.
.
.
Private Sub txtInput_Change()
Dim strInput As String
Dim strArray() As String

strInput = txtInput
strArray = Split(strInput, ";") <---- note ";"
.
.

I would like to set ";" from my combo box instead, using the global variable delimiter. However I'm unable to find the appropriate "insert" command, anyone?

something like:


Code:
strArray = Split(strInput, someinsertcommand(delimiter))

Thanks!

How Do I Hold Quotes In A String Variable
Suchas


VB Code:
[code]Dim X as StringX = "<?xml version="1.0" standalone="yes"?>"[/code]


so that later I can print into a file...


Code:
<?xml version="1.0" standalone="yes"?>



Old Timer using VB5.0

Thanks

Type Mismatch String Containing Quotes
We're trying to develop an application that resembles the MS SQL Query Analyzer for WMI. When we run a WQL query against a namespace everything works fine until we get to a property that contains quotes and then we get a type mismatch error.


VB Code:
Private Sub Command1_Click()    Dim WbemServices       As SWbemServices    Dim WbemLocator        As New SWbemLocator    Dim objResult          As SWbemObject    Dim wosResults         As SWbemObjectSet    Dim iCounter           As Integer    Dim iIncrement         As Integer    Dim sValue             As String        ListView1.ListItems.Clear        GetColumns mQueryExp        Set WbemServices = WbemLocator.ConnectServer(gstrServer, "rootsmssite_NSC")        ' Set the impersonation level    WbemServices.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate        Set wosResults = WbemServices.ExecQuery(mQueryExp)        For Each objResult In wosResults        iCounter = iCounter + 1                For iIncrement = 1 To mColColumns.Count            sItem = mColColumns.Item(iIncrement)            If iIncrement = 1 Then                ListView1.ListItems.Add , , CStr(objResult.Properties_([sItem]).Value)            Else                ListView1.ListItems(iCounter).ListSubItems.Add , , CStr(objResult.Properties_([sItem]).Value)            End If        Next iIncrement    Next End Sub


We're using the select statement to get the column names and putting them into a collection.

Any ideas?

Removing Quotes From A String * RESOLVED *
Is there a function I can use that will remove quotes from a string. e.g "Hello world" is my string but I just want Hello world.

I realise I could write my own function looping though one char at a time, but is there a better way?

Determine If String Is Surrounded In Quotes?
Hello...

i'm making a search type application and I want it to be advanced enough to search by a whole string if user types keywords in quotes, or by individual words if user doesn't have them in quotes....

so, how do i determine if a string is surrounded in quotes?

lets say user submits these keywords:

"Shop and Save"

i need to know if the string is in quotes or not.... if not, i'd like to split the words into an array and go from there....

ideas?

Need A Decent Programmer For This One I Think {dealing With Quotes In SQL String}
Dont know whats wrong with this:


Code:
'Make sure there is not an apostrophe in txt or short Description
'If there is add another to eliminate sql Execution problem

If InStr(Me.txtText.Value, "'") > "0" Then
Dim TmpSql As String
TmpSql = Me.txtText.Value
TmpSql = Replace(TmpSql, "'", "'" & " & " & """'""" & " & " & "'")
TmpSql = TmpSql
Debug.Print TmpSql
Else
TmpSql = Me.txtText.Value

End If


'this is supposed to stripout and replace and apostrohe in order to be appended to the following Sqlstring:


SqlString = "Insert into TblIrc_CallLog (" & _
"TblIrc_CallLog.[MemNo], TblIrc_CallLog.[CallDate], " & _
"TblIrc_CallLog.[Caller],TblIrc_CallLog.[ShortDesc], " & _
"TblIrc_CallLog.[TechInt],TblIrc_CallLog.[Status], " & _
"TblIrc_CallLog.[Text],TblIRc_CallLog.[TakenBy]) Values ('" & _
Me.MemNo.Value & "', '" & Me.txtCallDate.Value & "', '" & _
Me.txtCallerName.Value & "', '" & Me.txtShortDesc.Value & "', '" & _
Me.cmbTechInt.Column(1) & "', '" & Me.cmbStatus.Value & "', '" & _
TmpSql & "', '" & Me.cmbTakenBy.Value & "');"


in debug mode it look perfect to me. this is the output of debug.print mode:


---for replace string function
X215 - SPECIAL AUTO POLICY/PARENTAL LIAB - ORIGINALLY CAME IN TO JILL BUT SHE STATED IT IS MORE OF COVERAGE ISSUE. THEY HAVE A HUSBAND/WIFE THAT HAVE PROPER AUTO COVERAGE. THEY HAVE A 23 YEAR OLD SON WITH CP LIVING IN THE HOUSEHOLD. THEY ARE TRYING TO FIND OUT IF THEY SELL OR GIVE A VEHICLE TO THE SON AND HE GETS A SPECIAL AUTO POLICY, WOULD THIS CREATE A WALL THAT THE PARENT' & "'" & 'S COULDN' & "'" & 'T BE SUED, OR WOULD THIS CAUSE MORE OF A PROBLEM FOR THE PARENT' & "'" & 'S SINCE HE LIVES AT HOME? WOULD LIKE TO DISCUSS THE PARENTAL LIABILITY ISSUE


--and for SQLstring



Insert into TblIrc_CallLog (TblIrc_CallLog.[MemNo], TblIrc_CallLog.[CallDate], TblIrc_CallLog.[Caller],TblIrc_CallLog.[ShortDesc], TblIrc_CallLog.[TechInt],TblIrc_CallLog.[Status], TblIrc_CallLog.[Text],TblIRc_CallLog.[TakenBy]) Values ('2950854610', '5/7/2004', 'TODD FINCH', 'SAP/PARENTAL LIAB', 'DC', '1', 'X215 - SPECIAL AUTO POLICY/PARENTAL LIAB - ORIGINALLY CAME IN TO JILL BUT SHE STATED IT IS MORE OF COVERAGE ISSUE. THEY HAVE A HUSBAND/WIFE THAT HAVE PROPER AUTO COVERAGE. THEY HAVE A 23 YEAR OLD SON WITH CP LIVING IN THE HOUSEHOLD. THEY ARE TRYING TO FIND OUT IF THEY SELL OR GIVE A VEHICLE TO THE SON AND HE GETS A SPECIAL AUTO POLICY, WOULD THIS CREATE A WALL THAT THE PARENT' & "'" & 'S COULDN' & "'" & 'T BE SUED, OR WOULD THIS CAUSE MORE OF A PROBLEM FOR THE PARENT' & "'" & 'S SINCE HE LIVES AT HOME? WOULD LIKE TO DISCUSS THE PARENTAL LIABILITY ISSUE ');

Embed Double Quotes Within A String? **** Resolved *****
Does anyone know how to embed double quotes within a string for example


Code:
He said "How do you do this"


I want to use this in a message box, write it out onto a form or into a textbox/label.

Any help will be greatly appreciated.

Cheers

Double Quotes Inserting String From Clipboard
I want to get rid of the double quotes when inserting from the clipboard into a string.
Tried Left$ and Right$ but the double quotes are outside the string.

Heres A Stupid Question: How Do You Make A String Contain Quotes?
I need to pass along quotes to another program via a string, and its not working out so well.

I'm going to look up the ASCII way to do it, maybe that'll work. If not, anyone have idea?

Its probobly so silly of a solution I'll eat my own face in annoyance

Thank you

Writing String To A Text File Without The Quotes Appearing
hello.....I need to writes a string onto a text file with VB.....but when I do it with the following statement,

Open "C:My DocumentsINLHS.DAT" For Output As #3
Write #3, "sample"

the string is written to the text file within quotes......like this:
 
"sample"

is there any way I can write just the string onto the text file without any quotes appearing (other than writing character by character)? like this :

sample

I tried typing 'write #3, sample' , it's giving me an error since it's no longer a string.......

Problem With Double Quotes In Rich Text String
Hi there,
I have developed a web application in which I have used Rich Text box activex control. When i retrieve the control's text that contains double quotes and save it in database(SQL) it saves properly.
The text is "NPGRJ"NI"
This text is stored in RTF format in the database.

When I retrieve the value from the database and assign it to Rich text box I get the value in RTF format till the double quote after letter "J", the rest is deleted.
The double quote after the letter "J" gives me a problem.

Can anyone there please help me out.

Thanks and regards,
Smiley

Remove Quotes Created By Opening File As Continuous String
I had a text file that I needed to replace certain fields with a variable if it met a certain criteria. I opened the file as a continuous string, and was able to accomplish the changes. The problem is that opening the file as a continuous string adds quotes around all of the entries. Is there a way to remove the extra quotes?

Example: In working file: MODE=NULL
Continuous String: "MODE="NULL""

I tried to replace the " with a space, but the database file I am feeding the file into is searching for MODE=, followed by the variable, no other character will work. So, is there a way to remove this added "?

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?

Double Quotes And Single Quotes Problems
Hello, I'm new to databases and I am working on this project from a book I'm reading, and I am having trouble understanding this code. What's with all the quotes, double and single. I'm having trouble distinguishing what goes with what. thanks

Code:
Private Sub cmdProdSearch_Click()
Dim sSearchText As String
sSearchText = txtProdSearch.Text
adProducts.Recordset.Find "Productname >= '" & sSearchText & "'"
End Sub

ReDim Preserve Adding String To String Array Causes Space In Bad Place
I have a chat program where the user has the ability to ignore certain users by typing "/ignore <username>". When they do this, the username will be added into a redimming (and preserving) string array. When chat information is brought through the winsock, it checks for the name in the array, and if it is there, it will not print the message. However, when I add the text, I check what the string is before it enters the array. For example, if I type "/ignore test" then the msgbox will display "/test/", the vertical bars are what I add in the msgbox, but are not part of the string. However, when it is searching the array, it pulls up "/ test/" with a space before the actual username.

Here is my code to check and what to do when:

Code:

Dim i As Long
        
        MsgBox lngIgnoreTotal '***
        
        For i = 0 To lngIgnoreTotal
            If lngIgnoreTotal <> 0 Then
                MsgBox "list= /" & strIgnoreList(i) & "/" '***
                MsgBox "mid= /" & Mid(strText, 3, (InStr(2, strText, ">") - 3)) & "/" '***
                If (" " + Mid(strText, 2, (InStr(2, strText, ">") - 2))) = strIgnoreList(i) Then
                    MsgBox "subaa" '***
                    Exit For
                Else
                    If i = lngIgnoreTotal Then
                        MsgBox "subab" '***
                        frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
                        frmChat.rtbChatBox.SelColor = vbBlue
                        frmChat.rtbChatBox.SelBold = True
                        frmChat.rtbChatBox.SelText = Left(strText, InStr(strText, ">"))
                        frmChat.rtbChatBox.SelBold = False
                        frmChat.rtbChatBox.SelColor = vbBlack
    
                        frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
                        frmChat.rtbChatBox.SelText = Mid(strText, (InStr(strText, ">") + 1), Len(strText))
    
                        frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
                    End If
                End If
            Else
                MsgBox "subb" '***
                frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
                frmChat.rtbChatBox.SelColor = vbBlue
                frmChat.rtbChatBox.SelBold = True
                frmChat.rtbChatBox.SelText = Left(strText, InStr(strText, ">"))
                frmChat.rtbChatBox.SelBold = False
                frmChat.rtbChatBox.SelColor = vbBlack
                
                frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
                frmChat.rtbChatBox.SelText = Mid(strText, (InStr(strText, ">") + 1), Len(strText))
                
                frmChat.rtbChatBox.SelStart = Len(frmChat.rtbChatBox.Text)
            End If
        Next i




Any ideas why it does this?

bgp1
Brandon Parker
http://www.thejokes.net

Edited by - bgp1 on 11/23/2003 10:15:52 PM

Double Quotes Inside Quotes
I get a compiler error using this code. How can I write this because I need to insert this code this way.

Thanks


Code:
NewSholder = Replace(sholder, ">i.", "color="#808080">i.")

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 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)

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