?
Solved

Runtime Error 2447: Invalid use of the . (dot) or ! operator or invalid parentheses.

Posted on 2009-07-09
24
Medium Priority
?
1,178 Views
Last Modified: 2013-11-27
FBPos is a text box.

I want to see if the two properties are the same. I understand I may need to invoke the Eval() function around the .Tag one, but first I need the compiler to stop vommiting.

So why does this line cause a run-time error?
If FBPos.Value = FBPos.Tag Then
...

Open in new window

0
Comment
Question by:travisjbennett
[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
  • 14
  • 10
24 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814113
where and when is the code run?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814119
from VBA window
Debug > Compile
correct any errors raised.
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814169
It's run as shown below, in the beginning of a subroutine for lostfocus.
I tried changing what was in the IF to something else, still same error.

Private Sub FBPos_LostFocus()
    If FBPos.Value = "" Or IsNull(FBPos.Value) Then

Open in new window

0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 1

Author Comment

by:travisjbennett
ID: 24814176
The error occurs on the IF line...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814222
is FBPos a bound control?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814236
try doing a compact and repair first.
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814245
No, it says Unbound in design view.
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814492
Nope... Compact & Repair didn't do it.
I'll post more code...
So again, the error occurs on the first line of "Private Sub FBPos_LostFocus()" which is coded like "If FBPos.Value = "" Or IsNull(FBPos.Value) Then..."
The code only spews in LogicMidFBPos_Change() 's call of FBPos_LostFocus().
 
Up'd to 500 pts.

Private Sub LogicMidFBPos_Change()
    FBPos.Tag = FBPos.DefaultValue
    If LogicMidFBPos.Value = "All" Then
        FBPos.DefaultValue = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use few short and generic terms to maximize results."
    End If
    If LogicMidFBPos.Value = "Any" Then
        FBPos.DefaultValue = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use many short and generic terms to maximize results."
    End If
    Call FBPos_LostFocus
    FBPos.Tag = ""
End Sub
 
 
Private Sub FBPos_GotFocus()
    If FBPos.Value = Eval(FBPos.DefaultValue) Then
        FBPos.Value = ""
        FBPos.ForeColor = RGB(0, 0, 0)
    End If
End Sub
 
 
Private Sub FBPos_LostFocus()
    If FBPos.Value = "" Or IsNull(FBPos.Value) Then
        FBPos.Value = Eval(FBPos.DefaultValue)
        FBPos.ForeColor = RGB(128, 128, 128)
    End If
End Sub

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814528
can i see your db?
check Attach File to initiate upload
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814542
I can cut out the form and show it to you that way... It'll take a few minutes though.
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814678
Ok, so get rid of the MDB file extension so that it becomes simply
Sample.accdb

Sample.accdb.mdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814701
i'll take a look at it later, when i am on a box with A2007
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814745
Alright, thanks.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24814777
if you can make an .mdb, i can take a look at it now
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24814884
Alright, so the error occurs as I use the second dropdown above any text entry field.
The line that the debug button points to has a comment after then then... that's the code I was trying to add and still want to...
Anyway, good luck!

Sample03.mdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24815404
change as shown, original code with ' on the front

Private Sub LogicMidFBPos_Change()

    FBPos.Tag = FBPos.DefaultValue
    If LogicMidFBPos.Value = "All" Then
'        FBPos.DefaultValue = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use few short and generic terms to maximize results."
        FBPos = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use few short and generic terms to maximize results."
    End If
    If LogicMidFBPos.Value = "Any" Then
'        FBPos.DefaultValue = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use many short and generic terms to maximize results."
        FBPos = "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use many short and generic terms to maximize results."
    End If
    Call FBPos_LostFocus
    FBPos.Tag = ""

End Sub


0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24815411
see the use of DefaultValue in Access Help
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815455
But what I'm trying to do is insert/remove the word "many" or "few" in the tip line, based on the contents of the any/all dropdown.
In order for the grey/blank/reset thing to work, I need to update the defaultvalue too. How can I do that?
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815459
Do I just need to set both at the same time?
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815520
I think I've got it down to the question of:
How do I get the line of code below to run in the immediate window?

? Eval(""Format: ""Phrase 1"", ""Phrase 2"", ""Phrase 3"", ""Word"""" & Chr(13) & Chr(10) & ""Tip: Use few short and generic terms to maximize results."")

Open in new window

0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815524
I just need to get the quotes, etc. right.
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815547
This works...
? Eval("""String Cheese "" & 1")

Open in new window

0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 24815589
use this

Private Sub LogicMidFBPos_Change()
    FBPos.Tag = FBPos.DefaultValue
    If LogicMidFBPos.Value = "All" Then
        FBPos.DefaultValue = Chr(34) & "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use few short and generic terms to maximize results." & Chr(34)
    End If
    If LogicMidFBPos.Value = "Any" Then
        FBPos.DefaultValue = Chr(34) & "Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word""""" & Chr(13) & Chr(10) & "Tip: Use many short and generic terms to maximize results." & Chr(34)
    End If
    Call FBPos_LostFocus
    FBPos.Tag = ""
End Sub
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24815607
Yep... I just got it to work with this...
Phew...
Beautiful! Thanks again Cap.

    Call FBPos_GotFocus
    If LogicMidFBPos.Value = "all" Then
        If LogicPreFBPos.Value = "do" Then
            FBPos.DefaultValue = """Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word"""""" & Chr(13) & Chr(10) & ""Tip: Use few short and generic terms to maximize results."""
            FBPos.Value = ""
        End If
        If LogicPreFBPos.Value = "do not" Then
            FBPos.DefaultValue = """Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word"""""" & Chr(13) & Chr(10) & ""Tip: Use few short and generic terms to maximize results."""
            FBPos.Value = ""
        End If
    End If
    If LogicMidFBPos.Value = "any" Then
        If LogicPreFBPos.Value = "do" Then
            FBPos.DefaultValue = """Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word"""""" & Chr(13) & Chr(10) & ""Tip: Use many short and generic terms to maximize results."""
            FBPos.Value = ""
        End If
        If LogicPreFBPos.Value = "do not" Then
            FBPos.DefaultValue = """Format: """"Phrase 1"""", """"Phrase 2"""", """"Phrase 3"""", """"Word"""""" & Chr(13) & Chr(10) & ""Tip: Use few short and generic terms to maximize results."""
            FBPos.Value = ""
        End If
    End If
    Call FBPos_LostFocus

Open in new window

0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 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