Solved

MS Access Form Browse Button

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

Accepted Solution

by:
Rey Obrero 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now