Help Me! Error When Open Existing File...

Sep 28, 2006

I'm begin study Microsoft Access but have error and don't know how!
(Please see the attach picture)

I'm use Window XP Pro and Office 2003.

I'm already update window and Jet 4.0 Service Pack 8 (SP8) for Windows XP at link but nothing to change (http://www.microsoft.com/downloads/details.aspx?FamilyID=2deddec4-350e-4cd0-a12a-d7f70a153156&DisplayLang=en)

Please advise me the way to repair this error!!!

View Replies


ADVERTISEMENT

Error Using Shortcut To Open A Database - Can't Find File

Nov 5, 2013

We have a new user who is unable to get into a database. Another user in the same office had no problems.

The other user is using:

"C:Program Files (x86)Microsoft OfficeOffice14MSACCESS.EXE" /wrkgrp"ServerNameShareNameSFTPSFTPWorkgroup.mdw" "C:SFTP Database V2.1 FESFTP Database V2.1 FE.mdb

The new user was not able to access the share at all using ServerNameShareNameSFTP until he changed the path to:

"C:Program Files (x86)Microsoft OfficeOffice14MSACCESS.EXE" /wrkgrp"ServerName.ACCT05.us.companyabbreviation.comSha reNameSFTPSFTPWorkgroup.mdw" "C:SFTP Database V2.1 FESFTP Database V2.1 FE.mdb"

Now he can get into the SFTP folder, but when he uses the shortcut, he gets an error stating Microsoft Access couldn't find the file ServerName.ACCT05.us.companyabbreviation.comSha reNameSFTPSFTPWorkgroup.mdw 1" "C:SFTP Database V2.1 FESFTP Database V2.1 FE.mdb" (Note the space and 1)

I created a new shortcut, and I was able to open the db using his target line, even though I can use the shorter one. For the new user, this still generates an error.

View 4 Replies View Related

Open A New Record Without Showing The Existing Records. THank You

Jun 27, 2006

Hi all,

How to open a fresh form without showing the existing records in the DB.


I.E I've 5 records in the DB. When I click on the add new form command button

Code: DoCmd.GoToRecord , , acNewRec

I want to have a fresh piece of form + I dont want the records which is in the DB to be shown.

Is that possible.

Thank You.

View 1 Replies View Related

Using Copy Of Existing Workgroup File On A New Db?

Jun 17, 2005

Hi all,

I've set up security on my database before with great success, and now I'd like to use the same workgroup file (a copy with a new name and location) to secure a nes db.

I open the new db, and join my earlier created mdw file. I'm prompted with that I have joined my workgroupfile.

I then set permissions for each user in the workgroupfile, remove admin rights for the admin user account, and assign admin rights to my own account. I am also the owner of thr db.

I now run the security wizard, and I make no changes to any checkboxes.

This goes nicely, and the wizard closes after making a backup file.

I now want to re-join the system.mdw file, so I don't get prompted with the logon dialog when opening a new db or an unsecured db.

If I now try to start my new secured db by double-clicking on the secured mdb file it opens ?????

Where am I going wrong?

Thanks in advance for any help.

View 6 Replies View Related

General :: Copy New MDB File Over Existing Database

Feb 28, 2014

How can I overwrite the existing Access database with another Access database without the need for the end user to get involved in the process.

I want the code to copy a new mdb file over the database I am using (!) and then automatically start the new mdb file...

View 9 Replies View Related

Modules & VBA :: Create New Backend File From Existing One

Nov 4, 2013

I'm trying to create a button that will open a save window so that user can select where and the name of a new backend file.

and create a new backend file from the one in use and link to the new open.

View 4 Replies View Related

Queries :: Link External File To Existing Database?

Apr 30, 2013

Basically it's trying to take all the files in a given directory and add them into a existing database.

I have a database called Permit. the database has a field called "SEAL" and they will be creating an additional field "SCART" to hold the contents of the file that exist in the directory. Each image file, in directory, is named the same as a unique record in Permit.

example:
Permit-SC might have unique record 532442
An image file would be name 532442.

If the image file matches a record in Permit the image should be added to permit in a field called "SCART". At this point I'm not certain if I want a link or the actual image included in the record. since there's a possibility of including the permit file on the website it might be cleaner to have it included.

View 7 Replies View Related

Modules & VBA :: Appending To Existing Excel File From Recordset

Apr 18, 2014

I'm spinning my wheels on this. Trying to copy a recordset into an existing excel file.

Private Sub cmdExport_Click()

Dim conn As ADODB.Connection
Dim conn2 As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strConnection2 As String
Dim wks As Excel.Worksheet

[code]...

View 2 Replies View Related

Modules & VBA :: File Open Dialog Does Not Allow Selection Of All File Types

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

Tables :: Migrating OLE File To Attachment Field In Existing Record

Mar 8, 2015

Exporting all the OLE files in a 2003 database.

Any way to automatically connect these file to an attachment field in the existing record.

View 7 Replies View Related

Modules & VBA :: Sending Report Data To Existing Excel File

Jul 15, 2014

in Access i have made a report with data and now my goal is that if i click on a button the data will be exported to a existing Excel file under the other existing data so in row A6. Is this possible true a VBA code?

View 2 Replies View Related

Backup Current Access File Using Vba While The File Is Open

Jul 11, 2007

I have a button in the form of the current access file. What I want to do is when the user click on the button,
triggered the vba to backup current access file. But since the file is currently open, is this possible? If yes, may I know how to do it with vba?

I have tried two methods but failed:
1) Use copytofile method, but I get permission denied due to file open;
2) Use dbengine.compactdatabase method, but it also has problem if the file is open.

View 3 Replies View Related

Open Text File Using Only First 7 Characters Of File Name

Nov 7, 2013

I need to open and process the data from a text file on the network.

The first 7 characters of the file name will be the same every day.

The rest of the file name will change from day to day.

There will only be one file in the folder that has those first 7 characters.

There are a total of about 120 text files in the folder every day - give or take - including the one I need to open and read.

View 6 Replies View Related

Adding New Field To Existing Table And Form - Getting Error

Jun 8, 2014

I'm trying to add a combo box field to an existing table and form. I added the new field to my existing table and set it up as an combo box added my row sources. Then added the new field to an existing form and now am getting a error stating "The record source "Table name and added field here" specified on this form or report does not exist. When I just make the new field a text box instead of combo box it works just fine.

View 2 Replies View Related

Modules & VBA :: Run-time Error 3021 While Updating Existing Record In DAO Recordset

Jun 16, 2014

I have a linked table to a DB2 database. this table contains key-pair values and has about 140k records.

I use a Sub to update the value of a specific record.

The sub starts by opening the needed DAO recordset
Then it uses the rs.Findfirst method
It checks if rs.Nomatch is not true (so the records exists!)
Then it starts updating the record with
rs.edit
rs!value1 = myvalue1,
rs!value2 = myvalue 2
rs.Update
There is where I get the '3021 No current record' error

I use the same sub on the same table to update to different parts. One part works the other gives me the error.

I have checked for typos.

View 5 Replies View Related

General :: Open Save File Dialog - Select File From Text Box And Save To Selected Location

Aug 8, 2013

I need code for save dialog file ,and select the file from textbox and save it to the selected location.i have only this code and i dont know what else i can do with this because it just opens the save file dialog !

View 1 Replies View Related

Open Any File

Jun 2, 2005

hi there,

I thought my problem would be a common one but after spending enough time on the net and all forums i couldn't find my answer... anyway... here is my problem. The database is about creating reference, the table contains multiple references, i create a folder where i'll put all the files to be attached

I wanna a create a link to a file... the thing are :
- i want to open any kind of file (or at least i specify in a table what kind of file to open (jpg, pdf, etc...)
- The name of the file is different for ever record...
Anyway i think it will be more clear with the code :


Private Sub File_Name_Label_DblClick(Cancel As Integer)
Dim rst As New ADODB.Recordset
Dim file As String
Dim fold As String
Dim i As Integer

'Open Table Folder
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.LockType = adLockPessimistic
rst.Open "SELECT * FROM Folders;"

fold = rst("Certificats")
rst.Close

rst.Open "SELECT * FROM FileType ORDER BY FileType.FileType DESC;"

'Find File

file = DocNo + rst("filetype")
If file <> "" Then GoTo OK
rst.MoveNext
OK:
'Open File
Application.FollowHyperlink file, , True
Bye:

'Close Table
rst.Close
Set rst = Nothing
End Sub

But there is an error (runtime error 490), any help would be appreciated

Thanks again ..

View 1 Replies View Related

Cannot Open .mdb File

Jan 25, 2007

Greetings,

I have a database I have been developing for some time that I can no longer access. I am running windows XP and Access 2003, I am the only user and it is stored on my local system. I was tweaking some VBA code in a few of the forms and closed the file which triggered the auto compact/repair. Everything appeared normal until I tried to open it again later. Now I cannot open the file, I do not get an error message or anything. When I click on the file Access opens and stops, never actually opens the database. If I try to open the file inside Access nothing happens. I have tried importing the objects into a new DB and still nothing happens inside Access. The real wierd part to me is that outside of Access everything is accessible. I can import tables from inside Excel with no trouble, I can put a button into a blank database that opens the other database through DAO and I can see all my tables, forms, data, etc. My problem is that I do not need the data, it is just test data at this point, I need to recover the VBA code from the Forms and I do not know how to do that without being able to open the database in Access.

Here is what I have tried so far (on copies of original DB):
-Compact and Repair inside Access: Nothing happens just like trying to do anything else with it inside Access
-Opened DB holding shift: Same Problem
-Copied file to two other Windows XP/Access 2003 systems: Same problem
-Used Jet Compact: The database file compacts successfully, still cannot open in Access
-Opened Access with /decompile: Same problem, Access opens, DB does not
-Created new DB and tried to import objects: Cannot open the old DB or see its objects
-Imported data from inside Excel: No problems, all tables/queries are available and all data appears correct
-Accessed file from new DB using DAO code: Everything appears normal, I can export the modules to text fine, but I have lots of code in forms that I cannot export
-Opened other databases in Access on same machine: No problems

I've done quite a bit of searching on this and have not found the same problem listed anywhere else. I do have daily backups so I'm not completely lost, but I made quite a few changes before it died that make it worthwhile for me to try and recover the file.

Any suggestions of other things to try? Is there any way to extract the VBA code inside a form from an .mdb file outside of Access?

Thanks for any ideas!

View 2 Replies View Related

Help - Cannot Open The File

May 30, 2007

Hi,

I was wondering if i could get some help here. I'm getting the following error message when trying to open MDB Access file.

Microsoft Access cannot open this file
This file is located outside your intranet or an untrusted site. ...

I did not get any problems like this before i upgraded my IE to IE-7 browser. I believe IE 7 has changed a bit of security setting there.

I can open up any apps(words, excel) without this error or problem apart from Access application. I then copied the Access file from my network drive onto my local machine - then it works fine.

I have been to IE-7 internet option tool to change the level of security especially the Local intranet and trusted site.
I have added in my Server IP address - 192.168.3.10 to Local Intranet. This doesn't help at all. I've run out ideas.

Note: this Access MDB file has already been on my server. I didnot get it from any emails. I got no problem with other PCs except for this PC i use.

Any help is appreciated.

Thank you in advance

View 2 Replies View Related

How Can I Open A .mdf File In Access

Jul 16, 2005

Hi,

We have an old SQL server here which has died a horrible death and I need to get the data it contains out!

I have the .MDF files etc but I cannot seem to open them or import them in microsoft access.

I dont need to do anything flashy with it, just look at the tables!

Can anyone help?

Thanks

:)

View 14 Replies View Related

Open Old Access File

Oct 6, 2005

I am not an experienced Access developer.

I have a .mdb file that was created with Access 2000. Before I upgraded to 2003, I opened the file source by holding down 'shift' and double clicking the file. Now when I do that, it runs the application. How can I open the source file again.

Thanks

Anthony

View 1 Replies View Related

File Open Query

Feb 10, 2006

I've need to be able to open up another db while in the current db.

Atm I have to start the db, then goto file open, goto the t: and then select the correct .mdb file, as I have no control over the db, this is the solution we were provided.

Now what I would like to do is ammend the main menu screen on the first Db so that it has a button that will automatically open the newer .mdb, but I can't work out the correct scripting I need.

Can someone possibly help me please.

View 3 Replies View Related

Open File From Text Box

Dec 29, 2004

Hello,

I have an Access database that needs to open a file. Unfortunately, the text file is named 17.Ghost.Y87777_Extract.txt, where Y87777 changes per file. What I am trying to accomplish is have a text box on a form that you will type in a value, such as the Y87777 and let the entire string open a text file through a VBA. The problem is that, in my VBA I get an error file not found. The text box is called txtImport. In my VBA, I have the code set up as:

Dim myRecord as string

myRecord = Me.txtImport

Then to open the file:

C:Import17.Ghost.MyRecord_Extract.txt

Does placing myRecord inside of the string cause the problem?

View 4 Replies View Related

Open File Dialog

Oct 26, 2006

Another question:

I used the suggested code from this forum to import a file with the open file dialog box. It works great to that point, but how do I specify which table I want it to populate with this data?? Thanks!

Here's the code:

vb Code: Original - vb Code Type tagOPENFILENAMElStructSize As LonghwndOwner As LonghInstance As LongstrFilter As StringstrCustomFilter As StringnMaxCustFilter As LongnFilterIndex As LongstrFile As StringnMaxFile As LongstrFileTitle As StringnMaxFileTitle As LongstrInitialDir As StringstrTitle As StringFlags As LongnFileOffset As IntegernFileExtension As IntegerstrDefExt As StringlCustData As LonglpfnHook As LonglpTemplateName As StringEnd TypeDeclare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As BooleanDeclare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As BooleanDeclare Function CommDlgExtendedError Lib "comdlg32.dll" () As LongGlobal Const ahtOFN_READONLY = &H1Global Const ahtOFN_OVERWRITEPROMPT = &H2Global Const ahtOFN_HIDEREADONLY = &H4Global Const ahtOFN_NOCHANGEDIR = &H8Global Const ahtOFN_SHOWHELP = &H10' You won't use these.'Global Const ahtOFN_ENABLEHOOK = &H20'Global Const ahtOFN_ENABLETEMPLATE = &H40'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80Global Const ahtOFN_NOVALIDATE = &H100Global Const ahtOFN_ALLOWMULTISELECT = &H200Global Const ahtOFN_EXTENSIONDIFFERENT = &H400Global Const ahtOFN_PATHMUSTEXIST = &H800Global Const ahtOFN_FILEMUSTEXIST = &H1000Global Const ahtOFN_CREATEPROMPT = &H2000Global Const ahtOFN_SHAREAWARE = &H4000Global Const ahtOFN_NOREADONLYRETURN = &H8000Global Const ahtOFN_NOTESTFILECREATE = &H10000Global Const ahtOFN_NONETWORKBUTTON = &H20000Global Const ahtOFN_NOLONGNAMES = &H40000' New for Windows 95Global Const ahtOFN_EXPLORER = &H80000Global Const ahtOFN_NODEREFERENCELINKS = &H100000Global Const ahtOFN_LONGNAMES = &H200000Function TestIt()Dim strFilter As StringDim lngFlags As LongstrFilter = 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!")' Since you passed in a variable for lngFlags,' the function places the output flags value in the variable.Debug.Print Hex(lngFlags)End FunctionFunction GetOpenFile(Optional varDirectory As Variant, _Optional varTitleForDialog As Variant) As Variant' Here's an example that gets an Access database name.Dim strFilter As StringDim lngFlags As LongDim 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_NOCHANGEDIRIf IsMissing(varDirectory) ThenvarDirectory = ""End IfIf IsMissing(varTitleForDialog) ThenvarTitleForDialog = ""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) ThenvarFileName = TrimNull(varFileName)End IfGetOpenFile = varFileNameEnd FunctionFunction 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 filenameDim OFN As tagOPENFILENAMEDim strFileName As StringDim strFileTitle As StringDim fResult As Boolean' Give the dialog a caption title.If IsMissing(InitialDir) Then InitialDir = CurDirIf IsMissing(Filter) Then Filter = ""If IsMissing(FilterIndex) Then FilterIndex = 1If 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.hWndAccessAppIf 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 functionWith 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 = 255End 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 ThenfResult = aht_apiGetOpenFileName(OFN)ElsefResult = 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.FlagsahtCommonFileOpenSave = TrimNull(OFN.strFile)ElseahtCommonFileOpenSave = vbNullStringEnd IfEnd FunctionFunction 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 & vbNullCharEnd FunctionPrivate Function TrimNull(ByVal strItem As String) As StringDim intPos As IntegerintPos = InStr(strItem, vbNullChar)If intPos > 0 ThenTrimNull = Left(strItem, intPos - 1)ElseTrimNull = strItemEnd IfEnd FunctionPrivate Sub Command20_Click()Dim strFilter As StringDim strInputFileName As StringstrFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv)", "*.csv")strInputFileName = ahtCommonFileOpenSave( _Filter:=strFilter, OpenFile:=True, _DialogTitle:="Please select an input file...", _Flags:=ahtOFN_HIDEREADONLY)End Sub'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 tagOPENFILENAMElStructSize As LonghwndOwner As LonghInstance As LongstrFilter As StringstrCustomFilter As StringnMaxCustFilter As LongnFilterIndex As LongstrFile As StringnMaxFile As LongstrFileTitle As StringnMaxFileTitle As LongstrInitialDir As StringstrTitle As StringFlags As LongnFileOffset As IntegernFileExtension As IntegerstrDefExt As StringlCustData As LonglpfnHook As LonglpTemplateName As StringEnd 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 BooleanDeclare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long Global Const ahtOFN_READONLY = &H1Global Const ahtOFN_OVERWRITEPROMPT = &H2Global Const ahtOFN_HIDEREADONLY = &H4Global Const ahtOFN_NOCHANGEDIR = &H8Global Const ahtOFN_SHOWHELP = &H10' You won't use these.'Global Const ahtOFN_ENABLEHOOK = &H20'Global Const ahtOFN_ENABLETEMPLATE = &H40'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80Global Const ahtOFN_NOVALIDATE = &H100Global Const ahtOFN_ALLOWMULTISELECT = &H200Global Const ahtOFN_EXTENSIONDIFFERENT = &H400Global Const ahtOFN_PATHMUSTEXIST = &H800Global Const ahtOFN_FILEMUSTEXIST = &H1000Global Const ahtOFN_CREATEPROMPT = &H2000Global Const ahtOFN_SHAREAWARE = &H4000Global Const ahtOFN_NOREADONLYRETURN = &H8000Global Const ahtOFN_NOTESTFILECREATE = &H10000Global Const ahtOFN_NONETWORKBUTTON = &H20000Global Const ahtOFN_NOLONGNAMES = &H40000' New for Windows 95Global Const ahtOFN_EXPLORER = &H80000Global Const ahtOFN_NODEREFERENCELINKS = &H100000Global Const ahtOFN_LONGNAMES = &H200000 Function TestIt()Dim strFilter As StringDim lngFlags As LongstrFilter = 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!")' 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 StringDim lngFlags As LongDim 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_NOCHANGEDIRIf IsMissing(varDirectory) ThenvarDirectory = ""End IfIf IsMissing(varTitleForDialog) ThenvarTitleForDialog = ""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) ThenvarFileName = TrimNull(varFileName)End IfGetOpenFile = varFileNameEnd 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 filenameDim OFN As tagOPENFILENAMEDim strFileName As StringDim strFileTitle As StringDim fResult As Boolean' Give the dialog a caption title.If IsMissing(InitialDir) Then InitialDir = CurDirIf IsMissing(Filter) Then Filter = ""If IsMissing(FilterIndex) Then FilterIndex = 1If 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.hWndAccessAppIf 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 functionWith 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 = 255End 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 ThenfResult = aht_apiGetOpenFileName(OFN)ElsefResult = 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.FlagsahtCommonFileOpenSave = TrimNull(OFN.strFile)ElseahtCommonFileOpenSave = vbNullStringEnd IfEnd 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 & vbNullCharEnd Function Private Function TrimNull(ByVal strItem As String) As StringDim intPos As IntegerintPos = InStr(strItem, vbNullChar)If intPos > 0 ThenTrimNull = Left(strItem, intPos - 1)ElseTrimNull = strItemEnd IfEnd Function Private Sub Command20_Click() Dim strFilter As String   Dim strInputFileName As String strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.csv)", "*.csv")strInputFileName = ahtCommonFileOpenSave( _Filter:=strFilter, OpenFile:=True, _DialogTitle:="Please select an input file...", _Flags:=ahtOFN_HIDEREADONLY) End Sub '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  


Thanks!!

KellyJo

View 1 Replies View Related

Open File Dialog Box

Mar 9, 2007

Hello,

I would like to put a cmdbutton on a form to open the File Dialog box directly from Access whereby users can search through folders and open a any file selected.
I have searched the web and found a link:

http://www.mvps.org/access/api/api0001.htm

I have copied the code into a module and the code behind the cmdbutton but getting an error.
Can anyone help me is finding a solution or an example? Thanks.

View 14 Replies View Related

Open PDF File With Viewer

Dec 16, 2013

In my VBA (access 2003) project, Im struggling to open a pdf file using Adobe viewer/Reader. Is it possible ?

View 4 Replies View Related







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