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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select a value into a control box on exiting a diff control box

Status
Not open for further replies.

matt19642

Technical User
Jan 25, 2005
4
GB
I Have a form based on one table - tblhorsevisits which has a composite primary key of horseid and dateofvisit and foreign keys of customerid and also saddleid.

All I want to do is when a user tabs out of the horseid control I want a different text control (labelled horse name) to be populated with the name of the horse that corresponds to the horseid value. This means I need to effectively say something like:

select horsename "into the horse name field on the form"
from tblhorse
where horseid = "the value of horseid on the form".

I do not know visual basic yet and have been struggling to work out how to do this using the form horseid event - "on exit", then macro builder - action is SetValue and then using expression builder to set the value.

I am sure it must be simple but am stuck!
 
Take a look at the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks very much - is there anywhere on-line that gives free documentation on these features. The Access on-line help is useful - but I am getting errors when it runs now and I can't see what I am doing wrong as I have used the expression builder, and have also tried copying exactly as the examples in the Access help. I am using :

DLookup([tblhorse]![Name],[tblhorse],[tblhorse]![Horse ID]=[Forms]![frmedithorsevisit]![Horse ID])

When running the form I get an error message:
"The Object doesn't contain the Automation object tblhorse.
You tried to run a visual basic procedure to set a property or method for an object. However, the component doesn't make the property or method available for Automation operations."

 
DLookup("[Name]","tblhorse","[Horse ID]=" & [Forms]![frmedithorsevisit]![Horse ID])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's brilliant - works now - thanks again.

I will have to do some more reasearch into this syntax - the book I bought doesn't have this level of detail, and the Help in Access didn't give me the & - guess this is more on the programming side which I thought initially I could get away with using the wizards....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top