Solved

MS Access Form Browse Button

Posted on 2009-07-09
2
272 Views
Last Modified: 2013-11-28
I have been utilizing the attached code to allow users to browse for a file within a directory and insert the filepath into a field. It worked great a few days ago, but all of a sudden it is giving an error: 'Compile Error: Sub or Function not Defined'

It highlights ahtAddFilterItem. I do not understand why it is doing this since it worked fine a few days ago. I cannot think of anything that changed.

Why am I getting this error?

Note: I did not generate this code, I found it here: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21554625.html?sfQueryTermInfo=1+access+brows+button+form+ms
Private Sub BrowseTREND_Click()
 
    Dim strStartDir As String
    Dim strFilter As String
    Dim lngFlags As Long
    
' Lets start the file browse from our current directory
     
    strStartDir = CurrentDb.Name
    strStartDir = Left(strStartDir, Len(strStartDir) - Len(Dir(strStartDir)))
 
    strFilter = ahtAddFilterItem(strFilter, _
                        "Word Documents (*.doc)", "*.doc")
 
    strFilter = ahtAddFilterItem(strFilter, _
                        "Excel Files (*.xls)", "*.xls")
    strFilter = ahtAddFilterItem(strFilter, _
                        "All files (*.*)", "*.*")
 
    Me.FilePath = ahtCommonFileOpenSave(InitialDir:=strStartDir, _
                     Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
                     DialogTitle:="Select File")
End Sub

Open in new window

0
Comment
Question by:bambgrl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 24812767
form the vba window
Tools > references
see if you have a reference prefixed with MISSING:

if you found nothing,
place your cursor at ahtAddFilterItem and press Shift + F2
it should take you to the sub or function
if you found ahtAddFilterItem sub/function
From Access window
Tools > Database utilities > compact and repair
then, from VBA window
Debug > Compile
try to correct any errors raised

if all things fail
do a decompile
see this link   http://www.granite.ab.ca/access/decompile.htm

after decompiling, create a blank db and import all objects


if you are still getting the error, recreate the form with the Browse button



0
 

Author Comment

by:bambgrl
ID: 24814262
excellent! problem solved. Thank you for all of your help.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question