Conditionally Clear Contents Pt2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

Many thanks to Ofer who help me along with others for the following code.
The idea is to clear a form based on certain contents. The Me.Note works
great. However, the Me.Module is based on a select query behind the form.
When I view the form I recieve the following error message. Any and all help
much appreciated. Thanks Debbie D.

Run-time error '2135' This property is ready-only and can't be set...

Private Sub CustID_AfterUpdate()
 
It sounds like your query is not updateable and you probably did not want to
change the record anyway, just hide the information. Why not just make the
controls invisible?

Private Sub CustID_AfterUpdate()
If Me.CustID.Column(0) = 0 Then
Me.Note.Visible = False
Me.Module.Visible = False
Else
Me.Note.Visible = True
Me.Module.Visible = True
End If
End Sub

You might want to put the same code in the Current event of the form depending
on how you are using the ComboBox.

Hi all,

Many thanks to Ofer who help me along with others for the following code.
The idea is to clear a form based on certain contents. The Me.Note works
great. However, the Me.Module is based on a select query behind the form.
When I view the form I recieve the following error message. Any and all help
much appreciated. Thanks Debbie D.

Run-time error '2135' This property is ready-only and can't be set...

Private Sub CustID_AfterUpdate()

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
RuralGuy,

Many thanks for the help. It works perfect again on the me.note but I get
this message for the me.module
'Compile Error' Method or member not found.. Any idea?

Thanks again Debbie D.
 
Hi Debbie.
I'm not sure, what you mean when you said that the field is based on a query.
If the field control source is a calculation or Dlookup, such
=Dlookup("FieldName","QueryName")
Then you can't assign a value to this field, you can write a requery to
refresh the display
Me.Module.Requery
Or
Me.Module.RecordSource = ""
But then the dlookup wont work any more.

So, it will help if I'll understand what you mean that the field is based on
a query
 
Ofer,

Here is the properties of the combox box in my form:

control source: [Module] in brackets and the query that enables me to select
which course subject the students is testing on is:

SELECT ECDL_Course_Modules.ECDLModuleID,
ECDL_Course_Modules.ModuleDescription FROM ECDL_Course_Modules ORDER BY
[ECDLModuleID];

ModuleID is just an number, ModuleDescription is the course ie [1]
[Internet Studies]. The combo is bound to column 1 and then hidden to just
chose the course listings. Hope that explains better. Thanks again.

Debbie D.
 
When you add square brackets to the control source of a field in the form,
the field is looking for a field in the form and not for a field in the table

If you want to bound it to a field in the table the loose the square brackets.

--
I hope that helped
Good luck


Debbie D. said:
Ofer,

Here is the properties of the combox box in my form:

control source: [Module] in brackets and the query that enables me to select
which course subject the students is testing on is:

SELECT ECDL_Course_Modules.ECDLModuleID,
ECDL_Course_Modules.ModuleDescription FROM ECDL_Course_Modules ORDER BY
[ECDLModuleID];

ModuleID is just an number, ModuleDescription is the course ie [1]
[Internet Studies]. The combo is bound to column 1 and then hidden to just
chose the course listings. Hope that explains better. Thanks again.

Debbie D.


Ofer said:
Hi Debbie.
I'm not sure, what you mean when you said that the field is based on a query.
If the field control source is a calculation or Dlookup, such
=Dlookup("FieldName","QueryName")
Then you can't assign a value to this field, you can write a requery to
refresh the display
Me.Module.Requery
Or
Me.Module.RecordSource = ""
But then the dlookup wont work any more.

So, it will help if I'll understand what you mean that the field is based on
a query
 
Sorry my mistake, when you write in the control source of the field
=[Module] it will look for a field in the form, but not just [Module], that
will be fine

When you run the SQL of the form, without the form, can you update the
Module field?
--
I hope that helped
Good luck


Debbie D. said:
Ofer,

Here is the properties of the combox box in my form:

control source: [Module] in brackets and the query that enables me to select
which course subject the students is testing on is:

SELECT ECDL_Course_Modules.ECDLModuleID,
ECDL_Course_Modules.ModuleDescription FROM ECDL_Course_Modules ORDER BY
[ECDLModuleID];

ModuleID is just an number, ModuleDescription is the course ie [1]
[Internet Studies]. The combo is bound to column 1 and then hidden to just
chose the course listings. Hope that explains better. Thanks again.

Debbie D.


Ofer said:
Hi Debbie.
I'm not sure, what you mean when you said that the field is based on a query.
If the field control source is a calculation or Dlookup, such
=Dlookup("FieldName","QueryName")
Then you can't assign a value to this field, you can write a requery to
refresh the display
Me.Module.Requery
Or
Me.Module.RecordSource = ""
But then the dlookup wont work any more.

So, it will help if I'll understand what you mean that the field is based on
a query
 
Debbie D. said:
Hi all,

Many thanks to Ofer who help me along with others for the following
code. The idea is to clear a form based on certain contents. The
Me.Note works great. However, the Me.Module is based on a select
query behind the form. When I view the form I recieve the following
error message. Any and all help much appreciated. Thanks Debbie D.

Run-time error '2135' This property is ready-only and can't be set...

Private Sub CustID_AfterUpdate()

Debbie -

"Module" is the name of a built-in, read-only property of an Access
form. If you also have a control or field named "Module", you'd do well
to rename it to avoid having VBA misunderstand your references to it.
However, for the short term, you can probably solve your problem by the
simple expedient of using the bang (!) operator instead of the dot (.)
to refer to the control. Instead of ...

write

Me!Module = Null
 
Back
Top