Does Not Support...

G

Guest

I 'think' this is an Access technical glitch but perhaps someone can
recommend a way of correcting it (I've searched the net and it appears to be
a recurring problem with no clear answers).

I put code into a field property event and now get an error message that
reads: "The expression On Get Focus you entered as the event property setting
produced the following error: Object or class does not support the set of
events." In an effort to resolve this, I've deleted all the code, leaving
only a remark (rem) as a placeholder...same error message. I've moved the
code from the On Get Focus event to other events and the message seems to
follow. Most of the code is along the lines of:
If Forms![SPCA]![Services].Form!Rabies = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
Else
Me.Rabies.Visible = False
Me.RabiesTag.Visible = False
End If

Any suggestions? Scott
 
B

Bob Hairgrove

I 'think' this is an Access technical glitch but perhaps someone can
recommend a way of correcting it (I've searched the net and it appears to be
a recurring problem with no clear answers).

I put code into a field property event and now get an error message that
reads: "The expression On Get Focus you entered as the event property setting
produced the following error: Object or class does not support the set of
events." In an effort to resolve this, I've deleted all the code, leaving
only a remark (rem) as a placeholder...same error message. I've moved the
code from the On Get Focus event to other events and the message seems to
follow. Most of the code is along the lines of:
If Forms![SPCA]![Services].Form!Rabies = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
Else
Me.Rabies.Visible = False
Me.RabiesTag.Visible = False
End If

Any suggestions? Scott

You cannot set a control's Visible or Enabled property to False while
it has the focus. Since you didn't say which control's OnGotFocus
event is being fired, it is hard to say exactly which commands are
causing the problem. But in general, events such as BeforeUpdate,
AferUpdate, etc. occur while the control still has the focus. However,
you can move the focus within most of the event procedures in code
(except for BeforeUpdate, I believe) by using the SetFocus method of
some other control first, then set Visible or Enabled to False.
 
G

Guest

I wish I'd asked this question about four hours ago! Many thanks.
--
SHB


Bob Hairgrove said:
I 'think' this is an Access technical glitch but perhaps someone can
recommend a way of correcting it (I've searched the net and it appears to be
a recurring problem with no clear answers).

I put code into a field property event and now get an error message that
reads: "The expression On Get Focus you entered as the event property setting
produced the following error: Object or class does not support the set of
events." In an effort to resolve this, I've deleted all the code, leaving
only a remark (rem) as a placeholder...same error message. I've moved the
code from the On Get Focus event to other events and the message seems to
follow. Most of the code is along the lines of:
If Forms![SPCA]![Services].Form!Rabies = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
Else
Me.Rabies.Visible = False
Me.RabiesTag.Visible = False
End If

Any suggestions? Scott

You cannot set a control's Visible or Enabled property to False while
it has the focus. Since you didn't say which control's OnGotFocus
event is being fired, it is hard to say exactly which commands are
causing the problem. But in general, events such as BeforeUpdate,
AferUpdate, etc. occur while the control still has the focus. However,
you can move the focus within most of the event procedures in code
(except for BeforeUpdate, I believe) by using the SetFocus method of
some other control first, then set Visible or Enabled to False.
 
M

Marshall Barton

Scott said:
I 'think' this is an Access technical glitch but perhaps someone can
recommend a way of correcting it (I've searched the net and it appears to be
a recurring problem with no clear answers).

I put code into a field property event and now get an error message that
reads: "The expression On Get Focus you entered as the event property setting
produced the following error: Object or class does not support the set of
events." In an effort to resolve this, I've deleted all the code, leaving
only a remark (rem) as a placeholder...same error message. I've moved the
code from the On Get Focus event to other events and the message seems to
follow. Most of the code is along the lines of:
If Forms![SPCA]![Services].Form!Rabies = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
Else
Me.Rabies.Visible = False
Me.RabiesTag.Visible = False
End If


Aside from the extraneous .Form in the If statement, the
code looks ok.

From your wording, I am unsure what you've actually done
with this. The phrase "field property event" is near
meaningless, so let's try to get out nomenclature straight
in hopes of communications clarity. A **Field** is a column
in a table/query, which does not have any events or event
properties. Most likely you mean a **Control** on a
form/report (e.g. text box). Controls have **Event
Properties** (e.g. OnGotFocus) where you can specify the
Access mechanism that you want to handle the event. An
event property can only contain a macro name, an = followed
by a function call, or, most common "Event Procedure]", but
the property can not contain VBA code as your post seems to
imply.

When you select [Event Procedure] for the property, you can
then click on the property's builder button ( [...] in the
right margin) to have the cursor moved to the **Event
Procedure** (e.g Private Sub Rabies_GotFocus() ) associated
with the event property. Your code would then be typed into
the event procedure. After that's done, use the VBA - Debug
- Compile menu option to compile your code and check for
errors. When the code compiles without error, then test
your form to see if the code is doing what you want.
 
G

Guest

Bob and Marsh, my sincere thanks to both of you...I'm learning! One thing
that I'm now a bit confused on (Bob) is 'where' to place the .visible=False
code. I had originally put it in the OnCurrent event but it didn't seem to
work right there so I put it in one of the control events (Marsh, is my
terminology getting better :) Any comments/recommendations would be
appreciated. In any event, a sincere thank you for your efforts on my
behalf. This stuff ain't exactly intuititve.
--
SHB


Marshall Barton said:
Scott said:
I 'think' this is an Access technical glitch but perhaps someone can
recommend a way of correcting it (I've searched the net and it appears to be
a recurring problem with no clear answers).

I put code into a field property event and now get an error message that
reads: "The expression On Get Focus you entered as the event property setting
produced the following error: Object or class does not support the set of
events." In an effort to resolve this, I've deleted all the code, leaving
only a remark (rem) as a placeholder...same error message. I've moved the
code from the On Get Focus event to other events and the message seems to
follow. Most of the code is along the lines of:
If Forms![SPCA]![Services].Form!Rabies = True Then
Me.Rabies.Visible = True
Me.RabiesTag.Visible = True
Else
Me.Rabies.Visible = False
Me.RabiesTag.Visible = False
End If


Aside from the extraneous .Form in the If statement, the
code looks ok.

From your wording, I am unsure what you've actually done
with this. The phrase "field property event" is near
meaningless, so let's try to get out nomenclature straight
in hopes of communications clarity. A **Field** is a column
in a table/query, which does not have any events or event
properties. Most likely you mean a **Control** on a
form/report (e.g. text box). Controls have **Event
Properties** (e.g. OnGotFocus) where you can specify the
Access mechanism that you want to handle the event. An
event property can only contain a macro name, an = followed
by a function call, or, most common "Event Procedure]", but
the property can not contain VBA code as your post seems to
imply.

When you select [Event Procedure] for the property, you can
then click on the property's builder button ( [...] in the
right margin) to have the cursor moved to the **Event
Procedure** (e.g Private Sub Rabies_GotFocus() ) associated
with the event property. Your code would then be typed into
the event procedure. After that's done, use the VBA - Debug
- Compile menu option to compile your code and check for
errors. When the code compiles without error, then test
your form to see if the code is doing what you want.
 
M

Marshall Barton

Scott said:
Bob and Marsh, my sincere thanks to both of you...I'm learning! One thing
that I'm now a bit confused on (Bob) is 'where' to place the .visible=False
code. I had originally put it in the OnCurrent event but it didn't seem to
work right there so I put it in one of the control events (Marsh, is my
terminology getting better :) Any comments/recommendations would be
appreciated. In any event, a sincere thank you for your efforts on my
behalf. This stuff ain't exactly intuititve.


Well, either your terminology is not on track yet, or you're
still making the same mistake. There is no OnCurrent event.
There is the form's OnCurrent property and there is the
Current event. I suspect that you want to put your code in
the Current event's event procedure (located by using the
builder button next to the OnCurrent property when you
select [Event Procedure] for the property).
 
G

Guest

Marsh,
Again, thank you for your insightful response. Just to make sure I am
getting this straight...
1. The controls on a form (e.g., text box) have no On Current event
2. Even though there is an 'On Current' listed under the 'Event' tab of the
form's property window, these are not really events per se--they are
properties--unless
a) a macro is called,
b) a function (=X) is called or
b) the elipsis button is pressed to bring up the modular code section and
VBA code is used to trigger the event.

I am trying to make sure my terminology is right. Perhaps you can recommend
a good reference book forme to buy?
--
SHB


Marshall Barton said:
Scott said:
Bob and Marsh, my sincere thanks to both of you...I'm learning! One thing
that I'm now a bit confused on (Bob) is 'where' to place the .visible=False
code. I had originally put it in the OnCurrent event but it didn't seem to
work right there so I put it in one of the control events (Marsh, is my
terminology getting better :) Any comments/recommendations would be
appreciated. In any event, a sincere thank you for your efforts on my
behalf. This stuff ain't exactly intuititve.


Well, either your terminology is not on track yet, or you're
still making the same mistake. There is no OnCurrent event.
There is the form's OnCurrent property and there is the
Current event. I suspect that you want to put your code in
the Current event's event procedure (located by using the
builder button next to the OnCurrent property when you
select [Event Procedure] for the property).
 
M

Marshall Barton

Scott said:
Marsh,
Again, thank you for your insightful response. Just to make sure I am
getting this straight...
1. The controls on a form (e.g., text box) have no On Current event
2. Even though there is an 'On Current' listed under the 'Event' tab of the
form's property window, these are not really events per se--they are
properties--unless
a) a macro is called,
b) a function (=X) is called or
b) the elipsis button is pressed to bring up the modular code section and
VBA code is used to trigger the event.

I am trying to make sure my terminology is right. Perhaps you can recommend
a good reference book forme to buy?


Sorry Scott, but I'm not a good one to recommend a good book
for beginning VBA and event handling. For detailed
reference, the Help files usually contain the definitive
information - with the huge caveat - if you can find it.
The index is terrible and I don't think you can even go
through the Contents from top to bottom and find everything.
A truely excellent book on Access is the Access <version>
Developer's Handbook by Litwin, Getz, Gilbert (SYBEX press).
It's well worth price, but it's not geared toward beginners.

Back to your terminology.
1. Controls do not have an OnCurrent **property**, so they
can not have a Current **event**

2. The list under the Events tab in the properties window
are the **properties** that control how you want to deal
with events. If the property is left blank, it means you do
not want to do anything with the event. If the property
contains the name of a macro, that means that you want
Access to run the macro when the event occurs. Similiarly
if the property contains =functionname(). If the property
contains [Event Procedure], it means that you want Access to
call the corresponding VBA procedure in the form's module
when the event occurs.

Events are triggered by various actions, usually by a user
doing something on a form. In the case of the Current
event, the user navigated to a record. When a record
becomes the current record (the **event**), Access checks
the form's OnCurrent **property** to see if you want to do
something in this situation. If Access finds [Event
Procedure] in the property, it calls the Form_Current
**procedure** in the form's module so you can do whatever
you want to handle the record.

I know this is confusing until you can wrap your brain
around the concepts. You seem to getting the idea here and
just using some of the words inappropriately. But most
people don't make as fine a distinction as I'm hammering on
here, so don't get too stressed out over it.
 

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