How to access data in a field in a table? ("Object required" error)

Talia Young

New member
Local time
Today, 17:04
Joined
Apr 19, 2002
Messages
6
I can't figure out how to access data in a field in a table. To access data in a control on a form I would just use:
variable = Forms![formName]![controlName].Text

But when I try to use that syntax on data in a table, I get an "Object required" error.

Any suggestions would be greatly appreciated.
 
You cannot work directly with a table. You need to use a form....
 
Oh no! That's so stupid! It's so much cleaner just to work directly with the table - why add an additional layer in between? Aargh.

Thanks for the tip.
 
Define "cleaner". You can design a form in Datasheet view that mimics the visual aspects of a table, but gives you access to code and other details a table does not have.

Working directly in a table is a good way to screw up your data.
 
You don't need a form to work with data, you can do it in a Function or Sub. You would need to use DAO or ADO to open a recordset based on the table or a query. Once you do that, you can refer to fields in that recordset.

Tell us more about what you're trying to do and we'll make suggestions.
 
I'm not sure what I meant by "cleaner." It just seems inefficient to search in a form with the exact same data as a table instead of just searching directly in the table. I see the point about messing up data, though.

I am trying to search in an address table which contains separate fields for the number and street of a given set of addresses. I can "find" for a given key without difficulty, but I would like to be able to assess a field in the found record, i.e., search for a street, and then examine the number in the first found record - if it is higher than the key, then do one thing, if it is lower than the key, then do another. Thanks to the previous suggestion, I created a datasheet form based on the table and have been able to do what I wanted through that, but I am now curious if there is another way. I will go read up on DAOs in the meantime.

Thanks thanks.
 

Users who are viewing this thread

Back
Top Bottom