Solved

Error Number: 2447 There is an invalid use of the . (dot) or ! operator or invalid parentheses.; Access 2010

Posted on 2010-08-31
15
825 Views
Last Modified: 2012-05-10
I have the follwoing error when I run the following line in code:

FilesDir = Dir(Me.FilePath)

it has been working in Access 2000, but since I changed to access 2010 I get this error.

Premissions are OK

0
Comment
Question by:JohnTall
[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
15 Comments
 
LVL 75
ID: 33570086
Is FilePath the Control Source for a control on a Form?

If so, try changing the Name property of the control to

txtFilePath ... and then try:

FilesDir = Dir(Me.txtFilePath)

mx
0
 
LVL 4

Expert Comment

by:mikesuss
ID: 33570152
Need a bit more code.  Me normally refers to the mdb that you are in, so I am not sure what you are trying to do.
0
 

Author Comment

by:JohnTall
ID: 33570228
Dim FilesDir As String
FilesDir = Dir(Me.FilePath)

IT CRASHES AT THIS LINE
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 75
ID: 33570264
"Me normally refers to the mdb that you are in,"
Well, that's not quite correct.  ME refers to the Form, Report or Class Module you are in.  And Form/Report modules are class modules.

JohnTall:

Did you try what I suggested in my first post ?

mx
0
 
LVL 13

Expert Comment

by:khairil
ID: 33570316
Hi,

If you like to get file path on the current Access file then try this

Dim FilesDir As String
FilesDir = CurrentProject.Path & "\" & CurrentProject.Name

OR you can try this which I think similar to your case...

Dim FilesDir As String
FilesDir = Dir(CurrentProject.Name)


Enjoy!
0
 

Author Comment

by:JohnTall
ID: 33570509
FilePath is a textbox on the form with the following control source:

=Application.CurrentProject.Path & "\" & CurrentDb.Properties("AppTitle") & "_Files\Inbox\"
0
 
LVL 75
ID: 33570609
JohnTall:

Did you try what I suggested in my first post ?
0
 

Author Comment

by:JohnTall
ID: 33570740
Yes, I changed the name property of the textbox to txtFilePath and I changed the reference in code as well, but the same error continues.

When I look at the text box in the form it displays #Name? instead of the path, maybe that some feature is missing. ?
0
 
LVL 75
ID: 33570817
Has the AppTitle custom property been set for this MDB / ACCDB ?

mx
0
 
LVL 75
ID: 33570830
For example, this works in a text box for me:

=[Application].[CurrentProject].[Path] & "\" & [Currentdb].[Properties].[Count]

0
 
LVL 75
ID: 33570851
But if I do this in the VBA Immediate window:

?Currentdb.Properties("AppTitle")

I get error 3270 ... Property Not Found.  And I get #Error in the text box.

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 33570891
HOWEVER ... technically, I don't think the Application and CurrentDB objects were ever supposed to work like that in a text ... and I'm pretty sure Microsoft has 'tightened' this up in A2010.  I've already seen at least on instance of a similar thing in my A2010 testing.

You many need to create a Function and call it from the text box

Public Function mGetPath() As String
   mGetPath =Application.CurrentProject.Path & "\" & CurrentDb.Properties("AppTitle") & "_Files\Inbox\"
End Function

and then in the Text Box Control Source ...

=mGetPath()

mx
0
 

Author Comment

by:JohnTall
ID: 33570930
Yes, it was set using the following code:

Public Sub SetMDBAppTitle()
   Dim dbs As Object
   Dim prp As Object
   Dim strTitle As String

   Const PROPERTY_NOT_FOUND As Integer = 3270
   Const TEXT_TYPE As Integer = 10
   ' Equivalent to DAO dbText data type.
   Const BOOL_TYPE As Integer = 1
   ' Equivalent to DAO dbBoolean data type.
   Const LONG_TYPE As Integer = 4
   ' Equivalent to DAO dbLong data type.

   On Error GoTo ErrorHandler

   Set dbs = Application.CurrentDb
   strTitle = "Setting *.MDB Startup Options"

   ' Try to set the property. If it fails, the property does not exist.
   dbs.Properties("AppTitle") = strTitle

   ' Refresh the title bar to reflect the change.
   Application.RefreshTitleBar

ExitLine:
   dbs.Close
   Set dbs = Nothing
   Set prp = Nothing
   Exit Sub

ErrorHandler:
   If Err.Number = PROPERTY_NOT_FOUND Then
      ' Create the new property.
      Set prp = dbs.CreateProperty("AppTitle", TEXT_TYPE, strTitle)
      dbs.Properties.Append prp
      Resume Next
   Else
      Resume ExitLine
   End If

End Sub



0
 

Author Closing Comment

by:JohnTall
ID: 33571014
Thanks mx
0
 
LVL 75
ID: 33571050
You are welcome.

I will confirm this tonight on my A2010 system ... see if that works in a text box.  Pretty sure not.

mx
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server 2005 running VERY slow on Virtual Machine 18 62
MS Access How To Make Exports Recognize Returns or New Lines As Shown On Form 7 46
MS Access query 16 56
CISCO WIFI 6 68
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

737 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