Modules & VBA :: Code To Search For TIF File And Then Open It
Aug 15, 2013
How to write some code that will search a known drive and folder structure for a tif file and on finding it, open that tif file.
The known drive/folder structure is as follows:
M:CustomerSatisfactionStdDGImages
or it could have the full path as follows:
prdfs01QUESTIONSCustomerSatisfactionStdDGImag es
and then there are the following folders which contain any number of tif images:
01_Q
02_Q
03_Q
04_Q
05_Q
06_Q
07_Q
10_Q
11_Q
12_Q
13_Q
14_Q
17_Q
18_Q
19_Q
20_Q
21_Q
23_Q
24_Q
28_Q
29_Q
30_Q
31_Q
32_Q
33_Q
34_Q
35_Q
36_Q
37_Q
38_Q
39_Q
AR_Q
HE_Q
SKY_SKY3B
I would like to have a button in a form that the end user clicks and they then enter the name of the tif file they are looking for and on pressing enter the file is searched for and if found it is automatically opened up for them to see, if it is not found then a message "File Not Found" is displayed.
I Believe that I will need something like this:
Code:
Dim FS As FileSystemObject
Dim filenum As Integer
Dim tmp As String
Dim Folder As Folder
Dim subFolder As Folder
Dim File As File
[Code] .....
It's when I get to this point that I've got stuck, I don't know how to structure the code required to do the search and on finding the tif file open it.
An example tif file I might search for is: 0H214_2CJ0001905.tif.
View Replies
ADVERTISEMENT
Jun 24, 2015
I have a form that has a subform on it. The main form shows a category of furniture and has custom navigation buttons and a search text box for asset numbers and command button that runs the search. The subform shows the asset numbers associated with that furniture category, sometimes there is only one asset number, in other cases there could be 60. There is a scroll bar to scroll through the asset numbers when there are too many to see in the initial window.
The buttons all work as they should except when I search for an asset number that is part of a category that has too many asset numbers to show in the main window. When this happens the "previous" and "next" navigation buttons do not take you to the previous or next record. All of the other buttons on the form work though - you can go to the first, or the last record, and you can search for a new asset.This is the code for the search:
Code:
Private Sub cmdAssetSearch_Click()
Dim rs As Object
If IsNull(Me.TextAsset) Or Me.TextAsset = "" Then
MsgBox "Please type in an asset number to search for.", vbOKOnly
Me.TextAsset.SetFocus
[code]....
I've also attached a picture of what I mean when I say there are more asset numbers than what the window shows.
View 6 Replies
View Related
Aug 24, 2007
Does anyone know the code for opening a specific notepad file from a button? I know there's a default button but it only opens a blank notepad page. I need to open some written instructions from a button you see.
Thanks.
View 3 Replies
View Related
Jan 5, 2007
Hello!
I am an access novice so was wondering in anyone can help me.
Can anyone post the code I need to enter to do the following;
1) Import a file from my local hard drive into a designated table in access
2) Export a number of tables back onto my local hard drive
I would like it so these actions occur when I click on the relevent command box on my form
Any help would be very much appreciated
View 1 Replies
View Related
Aug 8, 2013
this cod ein access vba for opening a file dialog and selecting a file in a textbox ..
Private Sub Command26_Click()
Dim fDialog As Object
Set fDialog = Application.FileDialog(msoFileDialogOpen)
[Code]....
this code,on the form i have a button whose click event is this code and a a text box with it which is text29.
It gives an erro
Run time error '2185':
you cant refernce a propery or method for a control unless the control has the focus .
View 1 Replies
View Related
Oct 4, 2013
I recently upgraded a DB from 2003 to 2013 and ran into the following problem.
I have a button that opens a file dialog box and allows the user to upload a file to a predetermined location (and store the address as a hyperlink). I borrowed this code from someone else on here and modified it slightly.
In any case, the button still works, but now when it opens it doesn't have an option for "All files" under file types. So I can upload MS Office files, text files, etc., but not PDF files which are by far the most common types my users upload.
Here's my code and a screenshot is attached.
Private Sub Command35_Click()
Dim dd As Integer
Dim fileDump As FileDialog
Set fileDump = Application.FileDialog(msoFileDialogOpen)
dd = fileDump.Show
[Code] ....
View 3 Replies
View Related
Dec 5, 2014
I have a access 2003 database, and i am wondering if i can't setup a search function in a form that will open a file in windows explorer?
What i would like to do is have a test box that i enter in a number for example: 1234 then have a button named "Search" hit that button and it opens a corresponding file in windows explorer named 1234, or just opens that folder directly..
View 14 Replies
View Related
Sep 4, 2014
I am using a datasheet view with dbl click code to open a form to a selected record. I was able to use pbaldy's code and it worked perfectly.
DoCmd.OpenForm "Asset Status", , , "[Project Number] = '" & Me.Project_Number & " ' "
Then I realized I really want to be able to go to other records after I have gone to this form and tried this:
Dim rs As Object
Dim lngBookmark As Long
'set variable to the current record
lngBookmark = Me.Project_Number
'open new form
[code]....
But to no avail. Project_Number is a text field.
View 12 Replies
View Related
Feb 25, 2015
Staff are monitored to make sure they are keeping up to date with our customers. A customer can have multiple projects going through the factory at any one time. Each customer has a record per project and a 'general' record. Ideally we would like our staff to be able to move the 'general' record when they update a project record as opposed to either having to find and then update the general record after, or forgetting and calling the customer again 2 days later!
Including a msgbox for the EnqNum seems to show the general record correctly, however being new to access I am unsure if I have the update part correct.
Code:
If Me.chkMoveGen.Value = "-1" Then
Dim EnqNum As Integer
EnqNum = DLookup("[e_id]", "tblEnquiries", "[c_id]=" & Me.txtc_id & " and [e_status] = " & "13")
DoCmd.RunSQL "UPDATE tblEnquiries " & _
" SET e_date_due=#" & Format(Me.txte_date_due, "MM/DD/YYYY") & "#" & _
" WHERE e_id= EnqNum"
View 3 Replies
View Related
Mar 11, 2014
I have a folder in which there are PDF files stored. Now in the Form, there is a combobox and I want the code so that when a Form is loaded then add all those PDF file names(only first 9 letters of that) in the combobox.
e.g if the PDF file name is ABCDE1990-YYY then add ABCDE1990 in the combobox. So if there 10 PDF files in the folder then add 10 names in the combobox.
View 5 Replies
View Related
Sep 10, 2014
I have searched for bits of code to copy other people better than I, and had some success but I am failing to complete, so it is now time for me to visit you all. I am trying to open a PDF from a button on a subform. The location of the PDF is specified in a field. I want to open the PDF and search for a Member ID criteria also listed in a field on the Form.This is my code:
Code:
Private Sub Text12_Click()
Dim strPath As String
Dim Searchmem As String
strPath = [Notetxt]
Searchmem = [MemID]
[code]....
Adobe Reader reports "There was an error opening this document. The file cannot be found." but then opens the file (that's something).So it's the "search" bit that is the problem, and I cannot for the life of me get my search parameter to be used.
View 5 Replies
View Related
Aug 1, 2013
I have a query that opens a listbox in a form. In the listbox I want to add a doubleclick event that opens a pdf document with the selected record in it. The record is in column 1 of the listbox.
I can't use the FollowHyperlink method of the colecction application due the record in the column is a Key. I am not sure if FollowHyperlink method can be used in a listbox
I have been checking codes in the web and I found this:
Private 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
ShellExecute Me.hwnd, "open", "D:SebDesktopGA-BDpdf est.pdf, "", "", 4"
However, I don't know how to organize the code in a logic way in Sub End Sub. Neither I don't know if the code is for the doubleclic event in the list box or a Module. If is for a module I don't know how to write the code in it.
View 7 Replies
View Related
Nov 12, 2014
I'me running on Win7, Office 2010, Acc2003 format (.mdb), writing data to Excel 2010 (.xlsx)I have code to create an Excel file, send record set data to it, and then add some formulas and formatting. I was trying to tune up the formulas, when I got a pull back:Access VBA code suddenly stops running, and the file gets displayed in Excel
Code:
'ApXl is Application.Excel
'xlWSh is the Excel WorkSheet
'rst is my DAO.Recorset
[code]...
The same happens when I have ApXl.Visible = True
View 10 Replies
View Related
Oct 27, 2014
I was tasked to create an application where by the user enters keywords into an Access form, and when he clicks the button, it will run the keywords against the file names stored in the table and automatically open the Word document that is the best match.
I have created a table query called Directory, which contains FPath (Z:), FName (Document1.doc) and Directory (Z:Document1.doc).
Code:
Private Sub Command2_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim filepath As String
Dim strSearch As String
If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
[Code] ....
This is the code that I am currently using to search and open the Word documents, however, this code only manages to open Microsoft Word program without loading any documents. Also, there are no error messages when I click the submit button.
View 3 Replies
View Related
Aug 4, 2014
Is there a quick way to export ALL VBA code to a text file/word document?
View 5 Replies
View Related
Oct 20, 2014
when I open a .msg file using
dim x as long
x = Shell("""C:Program Files (x86)Microsoft OfficeOffice15Outlook.exe"" /f ""D:mymessage.msg""")
how to access the fields "To", "CC", "Subject", "Date", "Body text", etc ?
My problem: I have a lot of files .msg (about 1000) and I want to put them in a single file (preferably in txt).
View 7 Replies
View Related
Nov 18, 2014
I want to open different .doc files by a button from access.
I want that the vba code checks where the current access database is located. In which folder the the current access database is.
In this file folder i have a folder called documents.
In this folder i have the .doc files.
Right now i have the following code.
Public Function getPath(ByVal iPath As String)
Dim fso As Object
Dim drive As String
Set fso = CreateObject("Scripting.FileSystemObject")
drive = fso.GetDriveName(CurrentDb.Name)
[Code] .....
The access database is in the folder Z:BUS MMM CGrimmMasterarbeitDatenbank
I would like to have something like
spath = getpath("documentswissen.doc")
How can i do that?
View 2 Replies
View Related
Oct 8, 2013
From access I'm calling a code in excel. My code in excel pops up a browser that allows the user to select what files they'd like to import. For various reasons I have to import data through excel, not directly to Access which is why the browser appears in excel instead of access. Essentially the user will select a word file which is imported into access through excel.
I'd like this browser to appear in access instead of excel though. If I move my browser from excel to access is there any way to have my code in excel reference the file selected in access? Or is there some way for this browser to appear without the user having to select the excel icon in the task bar? I essentially want the user to only see and interact with access, but because my browser is in excel this isn't possible right now.
View 2 Replies
View Related
Feb 28, 2014
Previously in Excel / Access 97 / 2003 I made a little tool that would search for files in specified locations - I modified the code so that it would search for files based on what was entered in cells.
I believe a lot of the old code doesn't work in Access 2010 and it seems like a lot of the old file searching code I used to use no longer works.
Is there code available that searches a directory and lists results?
View 1 Replies
View Related
Jan 14, 2014
Access 2007-10
Listbox created: List62 (I know I need to rename it, but for now)
Multi-select: Extended
Row Source Type: Field List
Row Source: qryFieldList
Open Query: qrySelectedFields (I added primary key to first column, just to have at least one destination field).
Goal: to select multiple fields within listbox, click on command button to open query "qrySelectedFields" with selected fields from list box.This is the code I have on the command_click:
Dim varItem As Variant
Dim strSQL As String
If Me.List62.ItemsSelected.Count = 0 Then
MsgBox "Please select one or more fields.", vbExclamation, "Healthcare REIT"
Me.List62.SetFocus
End If
[code]....
It does absolutely nothing - doesn't add the fields to "qrySelectedFields", doesn't open the query, notta.
View 8 Replies
View Related
Sep 9, 2013
I am trying to create some code for a button in a report that will follow a hyperlink to a specific file. The problem I'm having is that the files that are at the end of the hyperlink can have various extensions (*.doc, *.docx, *.pdf, etc.) I'd like to be able to put a wildcard in the code to allow the opening of the file regardless of the extension.
Code so far:
Private Sub Command6_Click()
Application.FollowHyperlink ("C:UsersjbeggDocumentsAccessTestFolder" & [FileName] & ".*")
End Sub
View 11 Replies
View Related
Dec 8, 2014
What I want to do is... open a file dialog from VBA "This of cause is no problem" the file dialog is opened from a double click function of a textbox holding a link to a picture, what i want to happen is... when the explorer opens I want it to show only the picture that was linked in the textbox.
Example "C:markPhotosPicture 085.jpg"
the code i have so far is as follows...
Private Sub FilePathLbl_DblClick(Cancel As Integer)
Dim fFile As String
Dim fd As Office.FileDialog
Dim retVal As Variant
Set fd = Application.FileDialog(MsoFileDialogType.msoFileDialogFilePicker)
[Code] ....
It opens in the correct folder but it shows all the pictures in that folder.
View 3 Replies
View Related
Mar 11, 2015
I want to create a batch file that will be used in a RunApp macro command to open up another database.
View 2 Replies
View Related
Apr 27, 2015
I am trying to display an open file dialog window so that the user can pick up a file. I wish the window to show a specific folder. How can I do this? The code I am using is below. The parameter InitialFileName has no effect on the outcome.
Code:
Function GetFileName(strPath As String, imtype As String) As String
On Error GoTo Err_GetFileName
Dim Dlg As FileDialog
Dim sfl As FileDialogSelectedItems
Dim sflitem As Variant
Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
[Code] .....
View 11 Replies
View Related
May 25, 2015
I want to delete an excel file from within access vba. Problem is that if the file is open, it obviously cannot be deleted. so I need to check to see if that specific excel workbook is open and if it is, I want to close it before I can delete it.
All of the answers here involve creating an excel object and opening it before closing it. If I do that all that happens is a second instance of the workbook opens then closes leaving the originally open workbook still open.
Sub xx()
Dim XLapp As New Excel.Application
Dim ObjXL As Excel.Workbook
Set ObjXL = XLapp.Workbooks.Open("C:dropboxexcelimport.xlsx ")
ObjXL.Application.Visible = True
[Code] .....
The above code demonstrates my problem, if the import.xlsx file is already open then the code just opens another instance of this workbook and then closes it again leaving the original workbook open and as such cannot be deleted.
View 3 Replies
View Related
Sep 8, 2014
I am 2 years into my database. I am trying to find and open a folder based on a text box. The problem is folder could be in many sub folders which is hold on our J: drive.
To further complicate, the folder i am searching may not be exactly as the text box states.
EG. Text box could say 123456 however the folder could be called M123456 etc.
How do i locate a folder or subfolder and open it based on part of a text box...
View 3 Replies
View Related