Set Focus Erro 438

R

rebelscum0000

Dear All,

After update a field called Keyword, I call a module
If the User enters a duplicated Keyword, my code detects it and informs
the issue
If this happens, I need to move my focus to the Keyword Field in order
than the user enters another Keyword,

The problem here is I am getting an Error Number:
"438 Description Object doesn't support this property or method "


ElseIf Response = 7 Then

Forms!MainExclude_Form!MyKeyword = Null
Forms!MainExclude_Form!MyKeyword.SetFocus *Error
MsgBox Msg3, Stile3, Title3

Can someone please let me know what I am doing wrong?

Thanks in Advance
Kind Regards,
Antonio Macias
 
B

Bill Mosca, MS Access MVP

Is the table's field name MyKeyWord? If so, Access might be confusing the
field and the textbox. I suggest you preface all your text boxes with txt to
prevent the confusion as in txtMyKeyWord.
 
R

rebelscum0000

Dear Bill Mosca,

Are you suggesting me to do this?

Text Box: Keyword
Name........ Keyword
Control Source MyKeyword

To Replace to

Text Box Keyword
Name........ txtKeyword
Control Source MyKeyword

Is this the idea?

Thanks in Advance
Kind Regards
Antonio Macias
 
D

Dirk Goldgar

Bill Mosca said:
Is the table's field name MyKeyWord? If so, Access might be confusing
the field and the textbox. I suggest you preface all your text boxes
with txt to prevent the confusion as in txtMyKeyWord.

I think it more likely that the text box and the field do not have the
same name, so that "MyKeyword" is the name of the field, but not the
name of the text box. The text box control has a SetFocus method, but
the field does not.

Antonio, check the name of the text box on the form. If it's not the
same as the name of the field, either change it to be the same -- that
does work -- or change your code to use the name of the text box, not
the name of the field.
 
R

rebelscum0000

Bill,


i will re desing all my code, I prefer to ask before

I am going to replace

Text Box: Keyword
Name........ Keyword
Control Source MyKeyword


To


Text Box Keyword
Name........ DefaultKeyword
Control Source MyKeyword

if I replace the name in Text Box, Could you please help me to
determinate what
Do I have to change also in the following module?

TIA
Regards
Antonio Macias

Sub MyKeyword_InsertsINTO_Tbl_MyKeywords_Tbl()

Dim sQL3 As String 'Query, Variables more strongly
Dim MyKeywordININ As String 'My Keyword iNSERT INTO Default
Dim MyAppzPlusKeyPlusTbl 'My Appz Plus Keyword Plus Tbl
Dim Msg4 As String, Style4 As String, Title4 As String

On Error GoTo ErrorHandling

'Initialize Variables

MyKeywordININ = Forms!MainExclude_Form!Keyword


Msg4 = MyKeywordININ & " is Now your Default Search"
Style4 = vbOKOnly + vbInformation 'Define buttons.
Title4 = "Keyword Set" 'Define title.

'Make sure Microsoft DAO 3.6 Library in included in the References

'This SQL Statement INSERT INTO The Tbl MyKeywords_Tbl, The Entry of
'Forms!MainExclude_Form!Keyword (MyKeywordININ)
'Action Query Append

sQL3 = _
"INSERT INTO MyKeywords_Tbl ( MyKeyword ) " & _
"SELECT MainExclude_Tbl.MyKeyword " & _
"FROM MainExclude_Tbl " & _
"WHERE (((MainExclude_Tbl.MyKeyword) = '" & MyKeywordININ & "' )) "

CurrentDb.Execute sQL3, dbFailOnError

MsgBox Msg4, Style4, Title4

RunCommand acCmdRefresh

MyAppzPlusKeyPlusTbl = MyKeywordININ & "_Tbl"
Forms!MainExclude_Form!MyAppz = MyAppzPlusKeyPlusTbl

Exit Sub
ErrorHandling:
MsgBox "Error Number: " & Err & " Descripcion " & Err.Description
End Sub
 
B

Bill Mosca, MS Access MVP

Antonio

Code like this:
Forms!MainExclude_Form!Keyword
is referring to the textbox. Those are the ones you will have to change to:
Forms!MainExclude_Form!txtKeyword
 
R

rebelscum0000

Dear Bill,

I am changing my code as you suggested,

Text Box: DefaultKeyword
Name.......................... DefaultKeywod
Control Source..............MyKeyword

When the code runs there is no errors (438 Description Object doesn't
support this property or method) but I am still having problems trying
to move the focus
To the text box control "DefaultKeyword", the focus moves to the
next text box control

What else can I do?

Thanks in advance

Regards
Antonio Macias

Here is part of my code

ElseIf Response = 7 Then 'User chose No.
'MySelection = "No" 'Perform some action.

Forms!MainExclude_Form!DefaultKeyword = Null

MsgBox Msg3, Stile3, Title3

Forms!MainExclude_Form!DefaultKeyword.SetFocus ' Problem

End

ElseIf Response = 2 Then 'User chose Cancel.
'MySelection = Cancel 'Perform some action.

Forms!MainExclude_Form!DefaultKeyword = Null

MsgBox Msg3, Stile3, Title3

Forms!MainExclude_Form!DefaultKeyword.SetFocus 'Problem

End

End If
 
R

rebelscum0000

Bill

I "Fix" the problem, each time my focus moves to the next The text box
control
I moved back with the following code:

Private Sub DefaultAppz_GotFocus()
Forms!MainExclude_Form!DefaultKeyword.SetFocus
End Sub

Is not the a mega code but it works,

Thanks you :)

Regards,
Antonio Macias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top