Reference a record in table from a form

C

Charles Kingsley

I have a form called FormA. It is bound to TableA.

In FormA, I want to reference one of the fields in TableA, lets say FieldA.

Nornally I would have a text box control in the form and it's control source
would be FieldA and any code that I would use would reference the text box
control. All is fine and dandy.

This time, I want to do away with the text box and assign the current
record's value for FieldA to a variable.

In one database, I used this syntax in a VB module:

MyVariable= Me.FieldA

It works fine. That is MyVariable is given the value of the current
record's FieldA from the form's bound table, without the need of a text box
control.

I tried using the same syntax in another database but get a "Method or Data
member not found" error. If I use MyVariable= Me!FieldA (replacing the dot
with an exclamation point), it works fine.

Why?

Thanks
 
P

PC Datasheet

Use a bang "!" to reference objects and controls and a dot "." to reference
methods and properties and you won't run into this problem! (or should that end
in with a dot?)
 
C

Charles Kingsley

Thanks...but why does it work in one database but not the other ? The
second database is a copy of the first one. The only difference is that I
changed the names of the fields in the tables.
 

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