Solved

MS Access Form Browse Button

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

912 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

25 Experts available now in Live!

Get 1:1 Help Now