Change Event can't reference .text property

M

Mark A. Sam

Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I want the
AfterUpdate event to run when the user hits the delete key to clear the
ComboBox value. Here is the method. I moved the code to a button hoping I
could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the AfterUpdate
event to indicated to the ChangeEvent that AfterUpdate event fired first.
'This happens when selection is made from ComboBox rather then typing in
text.

End Sub

When I reference the .text property of the combo I get this message when
selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the control
has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
A

Allen Browne

Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is still
visible, but Access gets really confused and can throw the error you
describe.

More info:
http://allenbrowne.com/bug-06.html
 
M

Mark A. Sam

Allen Browne said:
Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no
records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is
still visible, but Access gets really confused and can throw the error you
describe.

More info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I want
the AfterUpdate event to run when the user hits the delete key to clear
the ComboBox value. Here is the method. I moved the code to a button
hoping I could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the
AfterUpdate event to indicated to the ChangeEvent that AfterUpdate event
fired first.
'This happens when selection is made from ComboBox rather then typing in
text.

End Sub

When I reference the .text property of the combo I get this message when
selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the
control has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
M

Mark A. Sam

Thanks for your respone Allen. The Combo is in the header section, but
moving it to the detail section didn't resolve the problem. B) and C) don't
apply to my situation. I'm not filtering, I'm setting the RecordSource and I
can add new records.

I won't argue that Access is confused, though. ;)

God Bless,

Mark

Allen Browne said:
Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no
records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is
still visible, but Access gets really confused and can throw the error you
describe.

More info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I want
the AfterUpdate event to run when the user hits the delete key to clear
the ComboBox value. Here is the method. I moved the code to a button
hoping I could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the
AfterUpdate event to indicated to the ChangeEvent that AfterUpdate event
fired first.
'This happens when selection is made from ComboBox rather then typing in
text.

End Sub

When I reference the .text property of the combo I get this message when
selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the
control has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
M

Mark A. Sam

Thanks Allen. I wrote out another response but the server trashed it. I
think becuase I agreed that Access gets confused. ;)

Ephesians 6:12

God Bless,

Mark


Allen Browne said:
Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no
records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is
still visible, but Access gets really confused and can throw the error you
describe.

More info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I want
the AfterUpdate event to run when the user hits the delete key to clear
the ComboBox value. Here is the method. I moved the code to a button
hoping I could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the
AfterUpdate event to indicated to the ChangeEvent that AfterUpdate event
fired first.
'This happens when selection is made from ComboBox rather then typing in
text.

End Sub

When I reference the .text property of the combo I get this message when
selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the
control has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
A

Allen Browne

If the form has records, the conditions I posted do not apply.

Ask Access what's going on. When the error occurs, drop to your error
handler, where you ask it:
Debug.Print Me.ActiveControl.Name

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Thanks for your respone Allen. The Combo is in the header section, but
moving it to the detail section didn't resolve the problem. B) and C)
don't apply to my situation. I'm not filtering, I'm setting the
RecordSource and I can add new records.

I won't argue that Access is confused, though. ;)

God Bless,

Mark

Allen Browne said:
Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no
records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is
still visible, but Access gets really confused and can throw the error
you describe.

More info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I want
the AfterUpdate event to run when the user hits the delete key to clear
the ComboBox value. Here is the method. I moved the code to a button
hoping I could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the
AfterUpdate event to indicated to the ChangeEvent that AfterUpdate event
fired first.
'This happens when selection is made from ComboBox rather then typing in
text.

End Sub

When I reference the .text property of the combo I get this message when
selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the
control has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
M

Mark A. Sam

Allen Browne said:
If the form has records, the conditions I posted do not apply.

The form has records. In fact, the combo sets the recordsource for the form
based on the selection
Ask Access what's going on. When the error occurs, drop to your error
handler, where you ask it:
Debug.Print Me.ActiveControl.Name

thats delivers the name of a control named [Dummy] which is a transparent
button used to receive the focus from two events, the AfterUpdate of another
combobox and the form's load event. It isn't addressed in any way from the
combobox in which the problem exists. In other words, Access is confused.
;)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Thanks for your respone Allen. The Combo is in the header section, but
moving it to the detail section didn't resolve the problem. B) and C)
don't apply to my situation. I'm not filtering, I'm setting the
RecordSource and I can add new records.

I won't argue that Access is confused, though. ;)

God Bless,

Mark

Allen Browne said:
Mark, this error can occur if these conditions are met:
a) The combo is in the Form Header or Form footer section
b) The form is filtered such that no records match (or there are no
records)
c) No new record can be added.

In this case, the Detail section of the form goes blank. The combo is
still visible, but Access gets really confused and can throw the error
you describe.

More info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Hello,

I have a procedure to set the RecordSource of a form in the AfterUpdate
event of a ComboBox. Using the Change event of the came Combobox I
want the AfterUpdate event to run when the user hits the delete key to
clear the ComboBox value. Here is the method. I moved the code to a
button hoping I could resolve this.

Private Sub TruckFilter_Change()

If TempVars("aUpdate") = False And [TruckFilter].Text = "" Then
[TruckFilter] = Null
Call RunFilterCode_Click
End If

TempVars("aUpdate") = False 'This variable is set to true in the
AfterUpdate event to indicated to the ChangeEvent that AfterUpdate
event fired first.
'This happens when selection is made from ComboBox rather then typing
in text.

End Sub

When I reference the .text property of the combo I get this message
when selecting from the Combo list.

Error 2185
You can't reference the a propety or method for a control unless the
control has the focus.

I'm puzzled as to why the control doesn't have the focus.

Thanks for any help and God Bless,

Mark A. Sam
 
A

Allen Browne

Well, if the command button is the active control, you cannot use the Text
property.

Unlike pure VB, in Access the Text property only applies while the control
has focus. So it might not be Access that is confused this time. :)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Allen Browne said:
If the form has records, the conditions I posted do not apply.

The form has records. In fact, the combo sets the recordsource for the
form based on the selection
Ask Access what's going on. When the error occurs, drop to your error
handler, where you ask it:
Debug.Print Me.ActiveControl.Name

thats delivers the name of a control named [Dummy] which is a transparent
button used to receive the focus from two events, the AfterUpdate of
another combobox and the form's load event. It isn't addressed in any way
from the combobox in which the problem exists. In other words, Access is
confused. ;)
 
D

David W. Fenton

Unlike pure VB, in Access the Text property only applies while the
control has focus. So it might not be Access that is confused this
time. :)

The VB .Text property is really more like the Access .Value
property, no?
 
M

Mark A. Sam

Allen,

The command button shouldn't be the active control. I am selecting from a
combobox and not transfering the focus. It is only when the .text property
is address that the problem occurs. It has to be a bug. I got it worked
out but how I did it is a mystery. I tried some bizarre thing and it
worked, so I'll leave it at that and hope Microsoft doesn't fix the bug.
I'll never remember why I did what I did...lol


Allen Browne said:
Well, if the command button is the active control, you cannot use the Text
property.

Unlike pure VB, in Access the Text property only applies while the control
has focus. So it might not be Access that is confused this time. :)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
Allen Browne said:
If the form has records, the conditions I posted do not apply.

The form has records. In fact, the combo sets the recordsource for the
form based on the selection
Ask Access what's going on. When the error occurs, drop to your error
handler, where you ask it:
Debug.Print Me.ActiveControl.Name

thats delivers the name of a control named [Dummy] which is a transparent
button used to receive the focus from two events, the AfterUpdate of
another combobox and the form's load event. It isn't addressed in any
way from the combobox in which the problem exists. In other words,
Access is confused. ;)
 
A

Allen Browne

Okay, Mark. I don't think I'm following you on this one.

Previously you said:
Debug.Print Me.ActiveControl.Name
thats delivers the name of a control named [Dummy] which
is a transparent button
But now you are saying it is not a button that has the focus.

Don't think I can help further on this.
 
M

Mark A. Sam

Exactly. [Dummy] is a button that receives the focus from another Combobox
called [FindLoad], but has nothing at all to do with the ComboxBox which I
am referring to named, [FilterTruck]. I probably shouldn't have gotten into
so much detail about it. I can see where it could cause confusion.

Combobox [FilterTruck] doesn't send the focus to any other control. When I
reference the .text property of [FilterTruck] in it's Change event, I get
the error and Me.ActiveControl.Name returns the name Dummy, which is a
button on the form. If I change button name to txtDummy, then
Me.ActiveControl.Name will return the new name. If I remove th button from
the form, it will return another control name. This is definately a bug.
But I found a solution so not an issue anymore, unless, possibly, Microsoft
fixes the bug.



Allen Browne said:
Okay, Mark. I don't think I'm following you on this one.

Previously you said:
Debug.Print Me.ActiveControl.Name
thats delivers the name of a control named [Dummy] which
is a transparent button
But now you are saying it is not a button that has the focus.

Don't think I can help further on this.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mark A. Sam said:
The command button shouldn't be the active control. I am selecting from
a combobox and not transfering the focus. It is only when the .text
property is address that the problem occurs. It has to be a bug. I got
it worked out but how I did it is a mystery. I tried some bizarre thing
and it worked, so I'll leave it at that and hope Microsoft doesn't fix
the bug. I'll never remember why I did what I did...lol
 

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