Solved

MS Access Form Browse Button

Posted on 2009-07-09
2
271 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
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

820 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