Graham, thanks for all the help. You'll have to excuse me I have
limited
programming knowledge. Where do I declare the function for the
ExecuteFile()? And if I plug in that function and the code for
it...then
plug the code below for the text box..this should all just flow?
Actually
I
wanted to add a button that the user pushes when finished inputing the
filename...I would put the code below for the button. I'm sorry if I
sound
confusing...I'm a bit confused myself. Thanks.
:
Kate,
Private Sub txtContractNo_AfterUpdate()
Dim sFileName As String
sFileName = "c:\somedirectory\" & Me!txtContractNo & ".pdf"
' Check that something exists in the textbox
If Len(Me!txtContractNo) > 0 Then
' Check if the record exists in the table
If DLookup("[ContractNo]", "tblContractsTable", "[ContractID]
= "
&
Me!txtContractNo Then
' Check if the file exists
If Len(Dir(sFileName, 1)) > 0 Then
' Open the file
ExecuteFile sFileName, "Open"
Else
DoCmd.Beep
MsgBox "File not found"
End If
Else
DoCmd.Beep
MsgBox "The file doesn't have a matching record"
End If
End If
End Sub
For the ExecuteFile() function, see
http://www.pacificdb.com.au/MVP/Code/ExeFile.htm
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
User will enter a number for a contract in a text box. The contract
number
is the primary key. After the user enters the number, if the number
exists
in the table I wanted to be able to search a folder on our network
to
see
if
that .pdf exits...if so I want to open the pdf for that contract
number.
Will I need code to do that? What may that look like?
Note...the folder and contract number will never change.