I can refer to some, but not all, of the fields in the RecordSource of a Form in the VBA code-behind. I have been careful to name the controls which provide data display/entry for the fields differently from the fields, and to name any variables differently from both fields and controls.
If I reference certain fields in an expression, I get a compile-time error "Variable not defined". Also, the same field names that throw this error do not appear in the Intellisense drop-down if I type, for example, "Me." to start an expression.
Looking through the fieldnames listed in the Intellisense drop-down, I note some entries there that have either been removed from the table or renamed; similarly, I note the absence in the list of some recently-added fields.
Finally, in the Form Design interface, the Control Source drop-downs for all controls show the correct, current list of field names for the RecordSource table.
It appears as though the VBA IDE is working from some stale, older version of the table schema -- it reflects the fieldnames as they were when the form was first designed, and does not reflect more recent changes to those fields and their names.
A specific example: my table dat_Tracts used to have a field in it called TractSub, and Form_Tracts had a control on it named cboTractSub whose ControlSource was TractSub. I subsequently renamed the field to TractSubCode, renamed the control to cboTractSubCode , and reset that control's ControlSource to TractSubCode. The form and control work fine, but if I try to reference TractSubCode or Me.TractSubCode in the VBA, I get the error. Furthermore, I note that Intellisense still includes Me.TractSub in its list even though there is no field nor variable with that name!
Does anyone recognize these symptoms? Is there a way to refresh/update VBA's "understand ing" of the fieldnames? Or is there some other explanation (and fix) for this problem?
Sorry to be long-winded but I want to be clear that this does not seem to be a simple case of confusing control and fieldnames or the like.
Many thanks in advance,
Chris
If I reference certain fields in an expression, I get a compile-time error "Variable not defined". Also, the same field names that throw this error do not appear in the Intellisense drop-down if I type, for example, "Me." to start an expression.
Looking through the fieldnames listed in the Intellisense drop-down, I note some entries there that have either been removed from the table or renamed; similarly, I note the absence in the list of some recently-added fields.
Finally, in the Form Design interface, the Control Source drop-downs for all controls show the correct, current list of field names for the RecordSource table.
It appears as though the VBA IDE is working from some stale, older version of the table schema -- it reflects the fieldnames as they were when the form was first designed, and does not reflect more recent changes to those fields and their names.
A specific example: my table dat_Tracts used to have a field in it called TractSub, and Form_Tracts had a control on it named cboTractSub whose ControlSource was TractSub. I subsequently renamed the field to TractSubCode, renamed the control to cboTractSubCode , and reset that control's ControlSource to TractSubCode. The form and control work fine, but if I try to reference TractSubCode or Me.TractSubCode in the VBA, I get the error. Furthermore, I note that Intellisense still includes Me.TractSub in its list even though there is no field nor variable with that name!
Does anyone recognize these symptoms? Is there a way to refresh/update VBA's "understand ing" of the fieldnames? Or is there some other explanation (and fix) for this problem?
Sorry to be long-winded but I want to be clear that this does not seem to be a simple case of confusing control and fieldnames or the like.
Many thanks in advance,
Chris
Comment