473,799 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

link microsoft word title to a value in access

I am having trouble getting my database to do what i want. I have a
form with autonumbers which are going to be the numbers of some
inventory. the inventory has reports in word or other program. The
file name is going to be the number generated by access, but every file
will be saved in the same folder. i was wondering if there was a way
to click on the button and then have the comput search the correct
folder linking the number in access to the file name and have that file
come up on the screen for viewing.

Jun 22 '06 #1
5 1599

enginerd477 wrote:
I am having trouble getting my database to do what i want. I have a
form with autonumbers which are going to be the numbers of some
inventory. the inventory has reports in word or other program. The
file name is going to be the number generated by access, but every file
will be saved in the same folder. i was wondering if there was a way
to click on the button and then have the comput search the correct
folder linking the number in access to the file name and have that file
come up on the screen for viewing.


create a text field in your table. Store either the full path to the
file or the name and then append the full path to the name

CONST cstrDirectory As STring = "C:\WordDoc s\"
then you'd store just the filename, if necessary. Making the Word
filename the same as the autonumber is a little dodgy. You're NOT
guaranteed that some numbers won't be skipped. Then you could do
something like formatting a calculated control as a hyperlink.

txtFilePath = cstrDirectory & Me.txtIDNo & ".doc"

If you format as a hyperlink, the file should open fine.

Jun 24 '06 #2
I'm a little confused so i'm just making sure i got this right, i just
started using access like three weeks ago and so im not as literal in
it as many of you.
So i need to save the files as any name. Then i have to make some
code, can i use the same one and just get rid of the text string and
put in yours, to give me the right directory. then i have to find a
way to get the filename stored in the database.
or
i can keep the same numbering and just create a hyperlink instead using
the autonumbers, or am i using that second part of code to open up the
top part or code.
Thanks for the help

Jun 26 '06 #3

enginerd477 wrote:
I am having trouble getting my database to do what i want. I have a
form with autonumbers which are going to be the numbers of some
inventory. the inventory has reports in word or other program. The
file name is going to be the number generated by access, but every file
will be saved in the same folder. i was wondering if there was a way
to click on the button and then have the comput search the correct
folder linking the number in access to the file name and have that file
come up on the screen for viewing.


If you're a newbie, this may be a bit hard to follow, so I'll try to
explain clearly. If the files already exist in the folder and the
records already exist in a table, but you don't have the full path
stored, you could use some code to get all this for you. (I did that
part for you. Hopefully it's what you wanted.)

All the code was cobbled from this NG or taken from The Access Web.

'---put all this code in a new code module.
Option Compare Database

'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHGetPathFromID List Lib "shell32.dl l" Alias _
"SHGetPathFromI DListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFold er Lib "shell32.dl l" Alias _
"SHBrowseForFol derA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYF SDIRS = &H1
Public Function BrowseFolder(sz DialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYF SDIRS
End With

dwIList = SHBrowseForFold er(bi)
szPath = Space$(512)
X = SHGetPathFromID List(ByVal dwIList, ByVal szPath)

If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
'*********** Code End *************** **

Then in the form that you want to use to launch the cataloging for you,
'********** Code Start *************** *
Option Compare Database

Private Sub Command0_Click( )
Dim strDirectory As String
Dim blnFileExists As Boolean
Dim rsFiles As DAO.Recordset

'---prompt the user for the folder to catalog.
strDirectory = BrowseFolder("S elect a folder to catalog")

'---open the table containing all the FileNumbers
Set rsFiles = DBEngine(0)(0). OpenRecordset(" tblFiles", dbOpenTable)

'---loop over all the records, look for the file (Dir), and if it
exists,
'---mark it as found/existing
'---and write the directory.

Do Until rsFiles.EOF
blnFileExists = (Len(Dir(strDir ectory & "\" &
rsFiles.Fields( "RecordID") & ".txt")) > 0)
With rsFiles
.Edit
!FileExists = blnFileExists
If blnFileExists Then
!FullPath = strDirectory & "\" &
rsFiles.Fields( "RecordID") & ".txt"
End If
.Update
End With
rsFiles.MoveNex t
Loop

rsFiles.Close
Set rsFiles = Nothing

End Sub

'*************C ode End************ *************
I was thinking that you might only want to ignore the files you had
already catalogued, but what if someone deletes one... then you'll get
a Null in your FullPath field.

Hope this makes sense. If you have questions, fire away.

Pieter

Jun 27 '06 #4
Thanks for the help, i found my mistake and got it to work.

i have another problem now. i have multiple file types in the folder
and i want all the files with the report name to open a when i click on
the button. i tried using the following code to see if i could get at
least one of the files to open but instead i got an error message
saying that Compile error: Else without If.

heres the code:

Dim filename As String
Dim file As String
Dim output As String

If filename = "\\averill\publ ic$\Engineering \Part_Database\ " &
CStr(Me!Report) & ".doc" Then Application.Fol lowHyperlink filename

ElseIf file = "\\averill\publ ic$\Engineering \Part_Database\ " &
CStr(Me!Report) & ".JPG" Then Application.Fol lowHyperlink file

Else
output = "No File for this Report Exists!"
End If

End Sub

Thanks for the help.

-------------------------------------------
pi********@hotm ail.com wrote:
enginerd477 wrote:
I am having trouble getting my database to do what i want. I have a
form with autonumbers which are going to be the numbers of some
inventory. the inventory has reports in word or other program. The
file name is going to be the number generated by access, but every file
will be saved in the same folder. i was wondering if there was a way
to click on the button and then have the comput search the correct
folder linking the number in access to the file name and have that file
come up on the screen for viewing.


If you're a newbie, this may be a bit hard to follow, so I'll try to
explain clearly. If the files already exist in the folder and the
records already exist in a table, but you don't have the full path
stored, you could use some code to get all this for you. (I did that
part for you. Hopefully it's what you wanted.)

All the code was cobbled from this NG or taken from The Access Web.

'---put all this code in a new code module.
Option Compare Database

'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHGetPathFromID List Lib "shell32.dl l" Alias _
"SHGetPathFromI DListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFold er Lib "shell32.dl l" Alias _
"SHBrowseForFol derA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYF SDIRS = &H1
Public Function BrowseFolder(sz DialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYF SDIRS
End With

dwIList = SHBrowseForFold er(bi)
szPath = Space$(512)
X = SHGetPathFromID List(ByVal dwIList, ByVal szPath)

If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
'*********** Code End *************** **

Then in the form that you want to use to launch the cataloging for you,
'********** Code Start *************** *
Option Compare Database

Private Sub Command0_Click( )
Dim strDirectory As String
Dim blnFileExists As Boolean
Dim rsFiles As DAO.Recordset

'---prompt the user for the folder to catalog.
strDirectory = BrowseFolder("S elect a folder to catalog")

'---open the table containing all the FileNumbers
Set rsFiles = DBEngine(0)(0). OpenRecordset(" tblFiles", dbOpenTable)

'---loop over all the records, look for the file (Dir), and if it
exists,
'---mark it as found/existing
'---and write the directory.

Do Until rsFiles.EOF
blnFileExists = (Len(Dir(strDir ectory & "\" &
rsFiles.Fields( "RecordID") & ".txt")) > 0)
With rsFiles
.Edit
!FileExists = blnFileExists
If blnFileExists Then
!FullPath = strDirectory & "\" &
rsFiles.Fields( "RecordID") & ".txt"
End If
.Update
End With
rsFiles.MoveNex t
Loop

rsFiles.Close
Set rsFiles = Nothing

End Sub

'*************C ode End************ *************
I was thinking that you might only want to ignore the files you had
already catalogued, but what if someone deletes one... then you'll get
a Null in your FullPath field.

Hope this makes sense. If you have questions, fire away.

Pieter


Jun 27 '06 #5
"enginerd47 7" <ke******@corni ng.com> wrote in
news:11******** **************@ j72g2000cwa.goo glegroups.com:
Thanks for the help, i found my mistake and got it to work.

i have another problem now. i have multiple file types in the
folder and i want all the files with the report name to open a
when i click on the button. i tried using the following code
to see if i could get at least one of the files to open but
instead i got an error message saying that Compile error: Else
without If.

heres the code:

Dim filename As String
Dim file As String
Dim output As String

If filename = "\\averill\publ ic$\Engineering \Part_Database\ " &
CStr(Me!Report) & ".doc" Then Application.Fol lowHyperlink
filename

ElseIf file = "\\averill\publ ic$\Engineering \Part_Database\ " &
CStr(Me!Report) & ".JPG" Then Application.Fol lowHyperlink file

Else
output = "No File for this Report Exists!"
End If

End Sub

Thanks for the help.


If then
do something
ElseIf then
do something
Else
do something
endif

NOT
If then do something
ElseIf then do something
Else do something
endif

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jun 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3287
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
1
2357
by: Andrew V. Romero | last post by:
I have a script that I am working on for an intranet tool and in this script I have a form, which when submitted the onSubmit command calls calculate(). In this calculate function, I have it do some calculations and write out a new document using document.write(). One of the lines it writes is (the whole script is at the bottom of this email). pageData = PageData+"<b>Patient Data</b><br>Wt: "+weight+" "+weightUnits+" &nbsp&nbsp Ht:...
3
1936
by: TrvlOrm | last post by:
I am having great difficulty in these asp scripts, using VBscript and JavaScript. I have 4 files that all need to be linked together. The first file "Books.html" - needs to search for a Book title, author or ISBN number from a Access database called "Books.mdb". When the user clicks Submit from the "Books.html" file (after inputting info in a text box and clicking the required box to define Title, Author or ISBN), the information is...
11
1376
by: WindAndWaves | last post by:
Hi Gurus What I would like to do is to setup a little form where people can put in a date (e.g. Day: Month..... Year , where ... is user input) and subsequently, will take them through to an anchor (<A NAME={date}></A>), relating to the date that they selected. As you may have worked out by now, I am a real novice when it comes to java script. I have a browse using Google, but so far no luck
7
3455
by: olga | last post by:
Hi, On my site, i want to pass a javascript variable to php. I know that this needs to done in a link or in a post. I want to know if there is a way i can do it with an html link. I should mention that these will be dynamically created links in php. This is an optional value so if javascript is disabled, my site will still function. the browser_width() function works correctly but when i
4
4842
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the value of the "id" field of that record as a URL parameter. Can someone tell me how to do this.
14
1999
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm just trying to do this in phases to understand what's going on. I'm getting an error (Object doesn't support this property or method) in IE and I can't figure out what I'm doing wrong. Can anyone tell me? if (navigator.appName == "Microsoft...
5
2481
by: md9108 | last post by:
I created, using some borrowed code, an asp search page for our intranet. I'm using frontpage 2003. When I publish I get that complation error on different lines at different times. They all seem to do with end if and elseif statements. The last one is from line 118. I highligted it. The code below is: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd"> <HTML> <HEAD> <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> <!--...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.