JohnTall
asked on
Error Number: 2447 There is an invalid use of the . (dot) or ! operator or invalid parentheses.; Access 2010
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
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
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.
ASKER
Dim FilesDir As String
FilesDir = Dir(Me.FilePath)
IT CRASHES AT THIS LINE
FilesDir = Dir(Me.FilePath)
IT CRASHES AT THIS LINE
"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
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
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!
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!
ASKER
FilePath is a textbox on the form with the following control source:
=Application.CurrentProjec t.Path & "\" & CurrentDb.Properties("AppT itle") & "_Files\Inbox\"
=Application.CurrentProjec
JohnTall:
Did you try what I suggested in my first post ?
Did you try what I suggested in my first post ?
ASKER
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. ?
When I look at the text box in the form it displays #Name? instead of the path, maybe that some feature is missing. ?
Has the AppTitle custom property been set for this MDB / ACCDB ?
mx
mx
For example, this works in a text box for me:
=[Application].[CurrentPro ject].[Pat h] & "\" & [Currentdb].[Properties].[ Count]
=[Application].[CurrentPro
But if I do this in the VBA Immediate window:
?Currentdb.Properties("App Title")
I get error 3270 ... Property Not Found. And I get #Error in the text box.
mx
?Currentdb.Properties("App
I get error 3270 ... Property Not Found. And I get #Error in the text box.
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.RefreshTitleBa r
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("AppTit le", TEXT_TYPE, strTitle)
dbs.Properties.Append prp
Resume Next
Else
Resume ExitLine
End If
End Sub
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")
' Refresh the title bar to reflect the change.
Application.RefreshTitleBa
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("AppTit
dbs.Properties.Append prp
Resume Next
Else
Resume ExitLine
End If
End Sub
ASKER
Thanks mx
You are welcome.
I will confirm this tonight on my A2010 system ... see if that works in a text box. Pretty sure not.
mx
I will confirm this tonight on my A2010 system ... see if that works in a text box. Pretty sure not.
mx
If so, try changing the Name property of the control to
txtFilePath ... and then try:
FilesDir = Dir(Me.txtFilePath)
mx