Cant adress data fields

  • Thread starter Thread starter DianePDavies
  • Start date Start date
D

DianePDavies

I have a form based on a table.

in the fields list I can see all the fields of the table, but somehow I
can't adress the fields simply by writing

me.fieldname = value

The strange thing is that it works in a subform... I have now controls in
the forms with the same name as the fields - so there is no conflict of
names. Only differnce is that in the subform I have an SQL-statement as
recordsource - and in the other form it is just the table.

How do I adress the fields in the recordsource?
 
DianePDavies said:
I have a form based on a table.

in the fields list I can see all the fields of the table, but somehow I
can't adress the fields simply by writing

me.fieldname = value

The strange thing is that it works in a subform... I have now controls in
the forms with the same name as the fields - so there is no conflict of
names. Only differnce is that in the subform I have an SQL-statement as
recordsource - and in the other form it is just the table.

How do I adress the fields in the recordsource?


Me.fieldname is good. Are you sure you are using the field
**name** and not its Caption?
 
I have a form based on a table.

in the fields list I can see all the fields of the table, but somehow I
can't adress the fields simply by writing

me.fieldname = value

The strange thing is that it works in a subform... I have now controls in
the forms with the same name as the fields - so there is no conflict of
names. Only differnce is that in the subform I have an SQL-statement as
recordsource - and in the other form it is just the table.

How do I adress the fields in the recordsource?

What's the context? Where are you trying to do this?
 
In the table "Issue" I have a field called "LastChangedBy". This name is in
the column Field Name whn the table is opened in design view.

In my form the Record Source is set to "Issue".

In VBA to this form I would normally be able to see the field by typing

Me.

then the editor would suggest the next step - including adressing data
fields for this form. But this does not happen - I cant see the data fields
of the record source.

This again leads to the problem described below.

Why cant I see my data fields?
 
DianePDavies said:
In the table "Issue" I have a field called "LastChangedBy". This name is in
the column Field Name whn the table is opened in design view.

In my form the Record Source is set to "Issue".

In VBA to this form I would normally be able to see the field by typing

Me.

then the editor would suggest the next step - including adressing data
fields for this form. But this does not happen - I cant see the data fields
of the record source.

This again leads to the problem described below.

Why cant I see my data fields?


I don't know why you can see them in one form and not in
aother. Maybe something is out of whack in that form,
possibly related to the VBA - Tools - Options - Editor -
Auto List Members option. I always thought that option
applied to the entire VBA project so I would expect it to
either show the list in all class modules/forms/reports or
not show it for anything.

That leads me to consider corruption as the cause of your
problem. First, make a backup copy of your MDB file. Then
you could try:
Copy the entire form's VBA code
Set the form's HasModule property to No
Close and save the form
Reopen the form
Paste the code into the now blank form module.
Compile the project

Decompiling your project might be better because it does
that kind of thing for all the code in the entire project.

IF the form's code is corrupted, it is likely that the cause
was editing the form's code while the form was not in design
view. ALWAYS switch to design view before making any code
changes.
 
I too suspect some kind of "coruption" to have happened. I shall try to
restore as per your suggestions.

What you say about ALWAYS use design mode is quite a thing. I have often
used the fact that I could modify the code while "running the form" in the
Access window - this is in fact a very nice feature....assuming that it works.

But I have over the years experienced funny incidents that required me to go
back a number of backups to restore functionality - this may be the result of
this procedure. Somehow Access should make sure you dont modify VBA with the
forms running...
 
DianePDavies said:
I too suspect some kind of "coruption" to have happened. I shall try to
restore as per your suggestions.

What you say about ALWAYS use design mode is quite a thing. I have often
used the fact that I could modify the code while "running the form" in the
Access window - this is in fact a very nice feature....assuming that it works.

But I have over the years experienced funny incidents that required me to go
back a number of backups to restore functionality - this may be the result of
this procedure. Somehow Access should make sure you dont modify VBA with the
forms running...


Either fix the problem or prevent us from doing things that
trip over it.

OTOH, the logic of editing code that is running is
extrordinarily complex, especially when you consider the
ability to not save the changes, back out some changes using
Ctrl+Z and compile on the fly. Which version of the
compiled code is the one you are running?, editing? or
saving?
 
Just restored my form. Had to paste all controls and the code into a blank
form + manually set the tab order for all fields again... but now it works -
and I can see the controls in VBA - and therefore also reference them in my
code.
 
=?Utf-8?B?RGlhbmVQRGF2aWVz?=
In the table "Issue" I have a field called "LastChangedBy". This
name is in the column Field Name whn the table is opened in design
view.

In my form the Record Source is set to "Issue".

In VBA to this form I would normally be able to see the field by
typing

Me.

then the editor would suggest the next step - including adressing
data fields for this form. But this does not happen - I cant see
the data fields of the record source.

This again leads to the problem described below.

Why cant I see my data fields?
In VBA, (the Intellisense feature of VBA to nail it down), what you
see when you type me. is not the field name of the record source, but
the name of the text/list/combo/box on the form that is bound to the
field in the recordsource.

You may have not bound a control to that field, so me. will not show
anything. You should be able to type me. and the field name into the
VB editor and the code will usually see it, even if Intellisense does
not.
 
Bob said:
In VBA, (the Intellisense feature of VBA to nail it down), what you
see when you type me. is not the field name of the record source, but
the name of the text/list/combo/box on the form that is bound to the
field in the recordsource.

You may have not bound a control to that field, so me. will not show
anything. You should be able to type me. and the field name into the
VB editor and the code will usually see it, even if Intellisense does
not.


That's not right. The control's AND record source fields
are added to the form's properties list (only the control if
its name is also a field name). In forms, unlike reports,
VBA code can refer to either. (Actually, Access creates a
runtime object called an AccessField to do this but these
things have their own issues.)

In reports, the field names will appear in the Intellisense
list. You can write code using them, but the code will not
run unless the field is bound to a control. This is because
Access creates its own internal query to use as the real
record source in order to deal with aggregate functions and
Sorting and Grouping stuff. This internally created query
only includes fields that are bound to a control so they are
not really there when the report is opened at runtime.
 
Yes - you can normally see controls and record source fields when typing "me."

I must say that the fact that controls often get the name of the record
source field has led to strange behaviour where data fields could not be
adressed properly. This is almost always solved by having slightly different
names for the controls.

The unknown is when a form gets corrupt. Then systematic debugging is very
difficult - but die to the explanations earlier on this thread this can
apparently most likely be avoided if code is not edited while the form is
running.
 
Back
Top