Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is the command in Access code

Status
Not open for further replies.

BingeThinker

Programmer
Mar 20, 2003
9
0
0
US
what is the command in Access code to bring back field data from a table or query?

do you use the DoCmd object?

I can get this far:

DoCmd.OpenQuery "QueryName"
DoCmd.GoToRecord acDataQuery, "QueryName", acFirst

But I don't know how to get to a specific field on that record and then bring that data back to my form!??



 
Read up on the Record Source property of the Form, and the Control Source property of the Control object. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
BingeThinker,

you could use the seek command and then reference the field you want and then use the me command to populate the form control.

I use something like this - could be an old way but it works for me :

dim data as database
dim table as recordset

set data = currentdb()
set table as recordset("table",db_open_table)

' I think the above is a very old way of referencing data etc but you can probably do it in a more efficient manner - shouldn't matter though.

if you were looking for a unique value that happens to be on your form you could do the following.

value = me!value
table.index = "value in table" ' note that this must be an indexed field in the table
table.seek "=", value

You are now at the value record and you can access the other data of the record.

so if you wanted say the cost of a product you could do the following :

me.cost = table("cost")

this will put the value of cost from the table of the record you have just seeked into the control cost of the form you are currently working on.

Hope this helps - even though I think I have confused myself with the explanation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top