Modules & VBA :: How To Browse Files And Store Them To Database

Jun 10, 2015

i want to browse the files from a form and then store hem to the database.i have the following code, i can show the file path to the text box but i don't know how to store the file or how to upload the file to the database.

Dim f As Object
Dim strFile As String
Dim strFolder As String
Dim varItem As Variant

[code]....

View Replies


ADVERTISEMENT

Modules & VBA :: Loop Through Files And Then Compare With Files In Database Table

Nov 11, 2013

I have to write a code for my database,i have folder with files "pending Review" and a table with column "tblExcelLocation". when i run my database all the files from pending review folder goes to "tblExcelLocation" on a click of button.But,if the files already exists it should not insert those files and insert the rest.For this i tried to write a code but i think i m unable to do that .

Code:
Loop through files in folder
folderspec = "O:QA FilesQC ReportingPending Review"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.files

[code]...

View 7 Replies View Related

Select Multiple Files With Browse Window

May 25, 2007

Thanks to a previous post, I was able to adapt the below code to call up a browse window in my project. However, the browse window only allows one file to be called up at a time. I would like to find a way to select multiple files in the browse window and call them all up at once. Please help

'***************** Code Start **************
'This code was originally written by Ken Getz.
'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:
' Microsoft Access 95 How-To
' Ken Getz and Paul Litwin
' Waite Group Press, 1996

Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long

Global Const ahtOFN_READONLY = &H1
Global Const ahtOFN_OVERWRITEPROMPT = &H2
Global Const ahtOFN_HIDEREADONLY = &H4
Global Const ahtOFN_NOCHANGEDIR = &H8
Global Const ahtOFN_SHOWHELP = &H10
' You won't use these.
'Global Const ahtOFN_ENABLEHOOK = &H20
'Global Const ahtOFN_ENABLETEMPLATE = &H40
'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80
Global Const ahtOFN_NOVALIDATE = &H100
Global Const ahtOFN_ALLOWMULTISELECT = &H200
Global Const ahtOFN_EXTENSIONDIFFERENT = &H400
Global Const ahtOFN_PATHMUSTEXIST = &H800
Global Const ahtOFN_FILEMUSTEXIST = &H1000
Global Const ahtOFN_CREATEPROMPT = &H2000
Global Const ahtOFN_SHAREAWARE = &H4000
Global Const ahtOFN_NOREADONLYRETURN = &H8000
Global Const ahtOFN_NOTESTFILECREATE = &H10000
Global Const ahtOFN_NONETWORKBUTTON = &H20000
Global Const ahtOFN_NOLONGNAMES = &H40000
' New for Windows 95
Global Const ahtOFN_EXPLORER = &H80000
Global Const ahtOFN_NODEREFERENCELINKS = &H100000
Global Const ahtOFN_LONGNAMES = &H200000

Function GetFile()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
' MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

GetFile = ahtCommonFileOpenSave(InitialDir:="C:", _
Filter:=strFilter, FilterIndex:=4, Flags:=lngFlags, _
DialogTitle:="Find File")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
'Debug.Print Hex(lngFlags)
End Function

Function GetOpenFile(Optional varDirectory As Variant, _
Optional varTitleForDialog As Variant) As Variant
' Here's an example that gets an Access database name.
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
' Specify that the chosen file must already exist,
' don't change directories when you're done
' Also, don't bother displaying
' the read-only box. It'll only confuse people.
lngFlags = ahtOFN_FILEMUSTEXIST Or _
ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR
If IsMissing(varDirectory) Then
varDirectory = ""
End If
If IsMissing(varTitleForDialog) Then
varTitleForDialog = ""
End If

' Define the filter string and allocate space in the "c"
' string Duplicate this line with changes as necessary for
' more file templates.
strFilter = ahtAddFilterItem(strFilter, _
"Access (*.mdb)", "*.MDB;*.MDA")
' Now actually call to get the file name.
varFileName = ahtCommonFileOpenSave( _
OpenFile:=True, _
InitialDir:=varDirectory, _
Filter:=strFilter, _
Flags:=lngFlags, _
DialogTitle:=varTitleForDialog)
If Not IsNull(varFileName) Then
varFileName = TrimNull(varFileName)
End If
GetOpenFile = varFileName
End Function

Function ahtCommonFileOpenSave( _
Optional ByRef Flags As Variant, _
Optional ByVal InitialDir As Variant, _
Optional ByVal Filter As Variant, _
Optional ByVal FilterIndex As Variant, _
Optional ByVal DefaultExt As Variant, _
Optional ByVal FileName As Variant, _
Optional ByVal DialogTitle As Variant, _
Optional ByVal hwnd As Variant, _
Optional ByVal OpenFile As Variant) As Variant
' This is the entry point you'll use to call the common
' file open/save dialog. The parameters are listed
' below, and all are optional.
'
' In:
' Flags: one or more of the ahtOFN_* constants, OR'd together.
' InitialDir: the directory in which to first look
' Filter: a set of file filters, set up by calling
' AddFilterItem. See examples.
' FilterIndex: 1-based integer indicating which filter
' set to use, by default (1 if unspecified)
' DefaultExt: Extension to use if the user doesn't enter one.
' Only useful on file saves.
' FileName: Default value for the file name text box.
' DialogTitle: Title for the dialog.
' hWnd: parent window handle
' OpenFile: Boolean(True=Open File/False=Save As)
' Out:
' Return Value: Either Null or the selected filename
Dim OFN As tagOPENFILENAME
Dim strFileName As String
Dim strFileTitle As String
Dim fResult As Boolean
' Give the dialog a caption title.
If IsMissing(InitialDir) Then InitialDir = CurDir
If IsMissing(Filter) Then Filter = ""
If IsMissing(FilterIndex) Then FilterIndex = 1
If IsMissing(Flags) Then Flags = 0&
If IsMissing(DefaultExt) Then DefaultExt = ""
If IsMissing(FileName) Then FileName = ""
If IsMissing(DialogTitle) Then DialogTitle = ""
If IsMissing(hwnd) Then hwnd = Application.hWndAccessApp
If IsMissing(OpenFile) Then OpenFile = True
' Allocate string space for the returned strings.
strFileName = Left(FileName & String(256, 0), 256)
strFileTitle = String(256, 0)
' Set up the data structure before you call the function
With OFN
.lStructSize = Len(OFN)
.hwndOwner = hwnd
.strFilter = Filter
.nFilterIndex = FilterIndex
.strFile = strFileName
.nMaxFile = Len(strFileName)
.strFileTitle = strFileTitle
.nMaxFileTitle = Len(strFileTitle)
.strTitle = DialogTitle
.Flags = Flags
.strDefExt = DefaultExt
.strInitialDir = InitialDir
' Didn't think most people would want to deal with
' these options.
.hInstance = 0
'.strCustomFilter = ""
'.nMaxCustFilter = 0
.lpfnHook = 0
'New for NT 4.0
.strCustomFilter = String(255, 0)
.nMaxCustFilter = 255
End With
' This will pass the desired data structure to the
' Windows API, which will in turn it uses to display
' the Open/Save As Dialog.
If OpenFile Then
fResult = aht_apiGetOpenFileName(OFN)
Else
fResult = aht_apiGetSaveFileName(OFN)
End If

' The function call filled in the strFileTitle member
' of the structure. You'll have to write special code
' to retrieve that if you're interested.
If fResult Then
' You might care to check the Flags member of the
' structure to get information about the chosen file.
' In this example, if you bothered to pass in a
' value for Flags, we'll fill it in with the outgoing
' Flags value.
If Not IsMissing(Flags) Then Flags = OFN.Flags
marty = strFile
ahtCommonFileOpenSave = TrimNull(OFN.strFile)
Else
ahtCommonFileOpenSave = vbNullString
End If
End Function

Function ahtAddFilterItem(strFilter As String, _
strDescription As String, Optional varItem As Variant) As String
' Tack a new chunk onto the file filter.
' That is, take the old value, stick onto it the description,
' (like "Databases"), a null character, the skeleton
' (like "*.mdb;*.mda") and a final null character.

If IsMissing(varItem) Then varItem = "*.*"
ahtAddFilterItem = strFilter & _
strDescription & vbNullChar & _
varItem & vbNullChar
End Function

Private Function TrimNull(ByVal strItem As String) As String
Dim intPos As Integer
intPos = InStr(strItem, vbNullChar)
If intPos > 0 Then
TrimNull = Left(strItem, intPos - 1)
Else
TrimNull = strItem
End If
End Function

View 1 Replies View Related

Need Your Opinion - Store/retrieve Word And Excel Files In Access 2003

Sep 4, 2007

Folks I need your help; just wanted to get your opinions here.

I work in a small engineering group and we have lots of reference documents in word and excel which we typically use for any projects. Currently, all these files are stored in Lotus Notes database. Unfortunately, they are pulling the plug on Notes license starting this fall. Therefore, I have been asked to see if there is a way we can store these files in Access as a repository and query the database whenever we need some information.

In order to avoid the database size getting too big, my thought was to store the .xls/.doc files as an “OLE object” data type, keep the files in local hard drive and create a link in a form to give the user to retrieve the information.

Do any of you have any suggestion on what is the best way to handle this?

Your input is highly appreciated.

Shan.

View 10 Replies View Related

Modules & VBA :: Edit Recent Files Of Access Database

Mar 18, 2014

Is it possible to edit the recent files of a access database?

We have a main database (version control database) from where you can open a database which is located on a network drive.

By selecting the datbase you need from a dropdown menu, access will check which version you have locally. If there is an updated version available on the network it will download this updated version, overwriting the old one. The 'main' database is then closed and the local version of the database you needed is opened.

The problem is that this local database is mentioned in the recent files history so people are able to bypass using the main database.

In Excel you can clear the recent files with application. Recent Files setting the maximum to 0 and back to original again. In Access you do not have this option.

Where I would be able to find this option. Ideally I'd like to only take out a specific databasename from the recent files, rather then resetting the full list.

View 2 Replies View Related

Modules & VBA :: Convert To Excel Files And Import Into Access Database

Aug 7, 2015

I have files that have extension of TSV which are text files but viewable in exel. I figured out a way for the user to click on a button in Access which does the following

1. Run Macro in Excel: The macro prompts the user to select the TSV file. After selection, macro opens the employee.tsv file in the excel (with excel being invisible) and saves it as employee.xls

Code:
Sub SaveTSVtoXLS()
Dim myPath As String
Dim myString As Variant
Application.DisplayAlerts = False
With Application.FileDialog(msoFileDialogOpen)

[Code] .....

2. Imports the Excel file (employee.xls) into two tables: tblEmployee and tblDepartment using the following codes.

Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "qryDepartment", selectFile, True - 1, "A1:C2"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "qryEmployee", selectFile, True - 1, "A1:AE2"

Everything is working flawless except that the user has to select the file three times:

1 time for the tsv
2 times for the xls file

Is there a way that the user can select the file only once (tsv file) or at least only twice one of the tsv file and the other for the xls file?

View 8 Replies View Related

General :: Browse Picture From Desktop And Insert Into Database

Feb 5, 2014

I need codes to browse pictures from desktop or folder and insert into access DB.

I am using Access 2010.

I also want the code to only insert the name of the picture and then link its folder through the ID or some text,ok?

View 1 Replies View Related

Modules & VBA :: Browse And Display In Hyperlink Textbox

May 16, 2014

I'm trying to use ghudson's browse button in a form on MS Access. It works well, but I'm running into a tiny bug after implementing it into my database.

[URL] ....

I am able to browse, I am able to select a file, and am also able to have it display into the hyperlink textbox.
However, when I try to click on the hyperlink in the textbox, it does not take me to the file.

To fix the bug, and to get the hyperlink working again, I have to modify the hyperlink within the textbox, then bring it back as it was. (generally, I hit backspace, and replace the letter I removed.)

View 6 Replies View Related

Modules & VBA :: Access 2010 Browse To Shows Only ONE Record?

Dec 11, 2013

The following code browse from one form to another and shows the record details I select in the first form which is what I need, however, the problem is it only shows that record and will not allow me go to next or previous records when pressing NEXT or PREVIOUS by saying this is the First Record or this is the Last Record.

Anyway to modify it to allow me navigate to other records.

Dim txtJobNumber As Integer
Private Sub Job_Number_DblClick(Cancel As Integer)
'Store Job_Number in txtJobNumber variable and display
message to show value.
txtJobNumber = [Job_Number]

[Code] ....

View 2 Replies View Related

Modules & VBA :: Browse For File Name And Place As String In Text Box?

Mar 10, 2014

I have created a form to send emails with attachments. The attachment path is specified in an unbound field which I have called [ToAttach] Rather than typing in the path, I want to use the browse function. I have inserted a browse button and can browse for the required file using following, but can't figure out how to place the file name in the unbound field as a string.

Code:
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = False
f.Show

View 7 Replies View Related

General :: MS Access Database - Show Long List Of Records When Browse In Datasheet View

Apr 12, 2014

I wonder how MS Access manage to show long list of records when we want to browse them in Datasheet view.

1 - Does it load limited amount of records on start-up and then load the remainder upon user interaction (scrolling for example)?

2 - Does it care about such things automatically or natively?

View 3 Replies View Related

Modules & VBA :: Browse For A File On Shared Drive And Link It To Record

Feb 24, 2015

I have a form displaying records. I would like the user to be able to select a button, browse for a file on a shared drive and link it to that record.

I have been exploring hyperlinking, which works for the most part, although I need it to display the share name rather than the drive assignment for that user. Such as drive1folder rather than C:folder.

Hyperlinking also unfortunatly requires the user to right click on a field select edit hyperlink then browse.

View 7 Replies View Related

Store ODBC Connection With Database

Mar 9, 2007

Really don't know the answer to this question and I thought I'd come to the experts. I have created an Access database that I use to push & pull data from an SQL database through linked tables. I created an ODBC connection on my PC and set it so the links keep the username and password for the ODBC connection. All that works great...Now my question - Is it possible to somehow "store" the ODBC connection within the Access database so that I don't have to go to every PC that is going to be running this database and create an ODBC connection? The Access database and the SQL database both exist on our network and all those that will be using it have access to both. If someone has the answer I would really appreciate it.

Thanks

View 8 Replies View Related

Proper Way To Store Attachments In A Database?

Apr 29, 2014

I have attachments I want to store in my database, most are images, some are excel files, etc. I'm sure its better to store a reference to the file instead of the attachment itself. Whats the best way to do something like this? Id like the attachment to still be displayed in the form if its an image...

View 3 Replies View Related

General :: Simple Store Keeping Inventory Database

Sep 9, 2013

I am trying to create a simple store keeping In and Out inventory database using Access, I thought I had made it but looks like I am missing something here.

The store works on SRV (Store Receiving Voucher) and SIV (Store Issue Voucher). Products will be added based on SRV and will be issued out based on SIV. So far I have created the tables as you can see in the figure. One thing I am not understanding is where to keep the record of the Current Quantity of each product, lets say an Item has been added or issue out, it should be added or deducted accordingly from that specific products overall quantity. Right now I have a sample field within products table as you can see with the name QtyOnHand but that doesn't seem to be logical.

View 7 Replies View Related

Modules & VBA :: Return Folder Directory To Text Box On Forms Record When Click Browse Command Button

Nov 12, 2014

I need to return a folders directory to a text box on my forms record called Files_Directory when i click the Browse command button... The folder will have more folders within it along with documents all relivant to the folder selected, hense the need for just the folder directory rather than a file.

View 12 Replies View Related

Continuously Collect Data From Received Emails And Store In A Database?

May 7, 2013

My department handles all two-way email communication with our customers. We have 8 different email addresses that we use depending on the customer service issue. I'm looking for a way to continuously collect 3 pieces of data from every email that is received: 1) Date Received, 2) Time Received, and 3) To Field (which of the 8 email addresses it was sent to).

As you can imagine the collection of this data to look for trends to assist with staffing needs, as well as analyze build reports for the company to review. I've been working with my IT department on this but they are not sure where to start. My guess is that I need to have them collect the data as it is coming into the email server, right? I'm good with VB and I've built some VBA scripts recently that collect Outlook information, but these only work if the computer I'm using stays on all the time which is not always practical. We'd like to have this database stored on one of our shared drives which collects this data indefinitely from our email server.

View 1 Replies View Related

Creating A Database To Store Training Records That Saves A Scanned Copy

Jun 8, 2015

I'm a access novice who is looking to create a database to store training records for permanent and agency staff, and contractors staff. I need the database to be able to produce reports on how many courses were trained over each month, and the total duration of the course completed (in hours).

View 2 Replies View Related

Modules & VBA :: Use Default Value To Store Data

Apr 23, 2014

I'm trying to use a form to store some usefull data on my database.

I'm using the DefaultValue property of the TextBoxes in this code:

Code:
Sub Comando17_Click()
Testo4.DefaultValue = """sasso"""
Testo6.DefaultValue = """sdr"""
Testo0.DefaultValue = Testo0.Value
DoCmd.Save
End Sub

Comando17 is the name of the button to run the macro
Testo4, Testo6 and Testo0 are the names of my TextBoxes
sasso and sdr are the values I want to set as Default

When I run this macro it changes the DefaultValue property on VBA local variables and the Value property, but the DefaultValue on the form structure remains unchanged.

View 7 Replies View Related

Modules & VBA :: Store Values During Calculation

Sep 23, 2014

I am trying to perform a calculation within an IF then Statement. The difference is I need Access to remember a values to complete the calculations prior to setting the final answer. I think this is basic however I am a novice and can't seem to get it to work.

Code:

If [Forms]![Jobentryfrm]![StyleJobCurrentSub]![Assembly] = 39 Then
BL = ([Forms]![Jobentryfrm]![Height] * 2) + ([Forms]![Jobentryfrm]![Length] * 2) + 8
bw = [Forms]![Jobentryfrm]![Length] + [Forms]![Jobentryfrm]![Width] + 12

[code]....

View 4 Replies View Related

Modules & VBA :: Store All Records In One Field?

Feb 20, 2014

I have a table like this :

Fields 1 --- field 2

A --- tuesday
A --- wednesday
A --- thursday
B --- tuesday
B --- wednesday

I want to end like this :

Fields 1 --- field 2

A --- tuesday,wednesday,thursday
B --- tuesday, wednesday

I was thinking of doing a loop in vba with recordset and a filter on field1 and concatenate the days of field2 in the first reccord of each letter.But my table is big so my code needs to be fast.

how to do this ?

View 3 Replies View Related

Modules & VBA :: Store Values Increment By 1

Nov 22, 2013

I'm building a database to organize the editing of a massive report my office is working on. I've got a big table of all the sections. Each section has a unique ID and a version number. I wrote the queries so that they return only the most recent version (i.e. the Max version # of each section.) The results of the query appear in a subform.

I was able to use VBA to allow the user to double click on the record in the subform, and look at the record in another form. (I was really proud of this.)

Anyway, it turns out what I need is to double click on the record in the subform, and create a new record based on this record, but increment the version # by one.

I've created an unbound form for this, and googled around. I need to use VB to store the variable, and then put it in the unbound text box.

View 11 Replies View Related

Modules & VBA :: How To Store A Query Into Temporary Table

Dec 11, 2013

I want to store a query into a table, which I will delete later on. But somehow it shows me an error: Data type conversion error at the qdf = CreateTableDef assignment line.

Code:
Public Sub LF_Query()
Dim i As Integer
Dim strSQL As String
Dim qdf As TableDef

[Code] .....

View 2 Replies View Related

Modules & VBA :: Code To Store PDF File Names In The Combobox?

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

Modules & VBA :: Using Array To Store Selected Items In List Box

Apr 10, 2015

I want to use an array to store data from a list box into a variable. I want it to be able to store one value, or multiple values, depending on what is selected.

Main problem: this list box feeds off a table which has employee names and their e-mails. The list box itself only shows the names, and when I select what I want the array to store is their e-mails, not their names.

Code:
Dim strNames As String
Dim varItem As Variant
Dim intCount As Integer
For Each varItem In Me.lstNames.ItemsSelected
intCount = intCount + 1
Select Case Len(strNames)

[Code] ....

That code successfully displays the item I selected, but only displays the name. I need to make it look in the table and get me column #2. I also want it to be able to select more than one item at a time.

View 5 Replies View Related

Modules & VBA :: Store Path Location Selected By User To A String

Feb 7, 2014

I am using this code

DoCmd.OutputTo acOutputReport, "rptFilter", "Excel97-Excel2003Workbook(*.xls)", strFilename, True, "", , acExportQualityScreen

With the OutputFile set to "" so the user can select the directory on where they want to store the exported template. I'm trying to figure out if I could get the file path and the file name and store it on a string so I could use it for something else.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved