Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access Form Browse Button

Posted on 2009-07-09
2
Medium Priority
?
276 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

926 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