Method or data member not found on setfocus

R-Berg

New member
Local time
Today, 15:17
Joined
Mar 19, 2024
Messages
3
I am generating a word file from a form.
It worked okay, but suddenly it found an error on SetFocus

But just on one specific location i can't see why.
The message comes on " Me.c169_pressure.SetFocus".

I don't see what is wrong there.

Code:
'  Ptest:
        Me.Ptest.SetFocus
             If Me.Ptest.Text = "" Then
            
             Me.Ptest.Text = "0"
                           End If
        FindText = "[ID03-PtGK]"
        ReplaceWith = Me.Ptest
        .Execute FindText:=FindText, ReplaceWith:=ReplaceWith, Replace:=2
        
       'Pressure:
        Me.c169_pressure.SetFocus
             If Me.c169_pressure.Text = "" Then
          
             Me.c169_pressure.Text = Me.MaxPressure.Text
                           End If
        FindText = "[ID02-PdGK]"
        ReplaceWith = Me.c169_pressure
        .Execute FindText:=FindText, ReplaceWith:=ReplaceWith, Replace:=2
 
I can see what the error is and think you are pointing us to the wrong line of your code

What does 'suddenly' mean? It was working and now it isn't? It compiles and fails on run? something else?

Why are you using setfocus? For what you are doing there is no need so far as I can see

If Me.Ptest = "" Then Me.Ptest = "0"
If Me.c169_pressure = "" Then Me.c169_pressure = Me.MaxPressure

And that should give you a clue as to the issue - .text is only available for the control that has the focus

 
What is up with your indentation?
 
does your control name have space on them?
you can try:

Me![c169 pressure].SetFocus
 

Users who are viewing this thread

Back
Top Bottom