Autofill Textbox Based on Table

M

mewins

I have a page where one enters in the number of adults and children and
txtTotUnitSz auto calculates the sum. I also have a tblTAFDC which has 2
columns, 1 for the family unit size (TAFDCUnit) and another for the amount of
financial aid that unit could get (TAFDCAmt). I would like to have another
box (txtTAFDC) take the value of txtTotUnitSz, reference it with my tblTAFDC
and return the appropriate value for TAFDCAmt (so the textbox looks at
txtTotUnitSz and pulls the TAFDCAmt for when txtTotUnitSz=TAFDCUnit). Asides
from creating a combo box that runs off a query and forcing the user to
manually select for TAFDCUnit, I can't seem to make it work. Is this even
possible? Thanks
 
D

David H

Sounds like you need to use the DLookup() function. A sample would be

=DLookup("txtFirstName", "tblUsers", "txtUserId = 'dch3'")

The first parameter is the name of the column that contains the data that
you need to retrieve. The second is the table name where the data is stored.
The third is the WHERE statement - the criteria used to search for the data.
Note the single ' around the text value.

Also, I might point out that you may want to reevaluate the naming
convention that you used. While you may know that tblTAFDC stands for
whatever it does. It means nothing to me. While I'm aware that the universe
doesn't revolve around me, your applicaltion and code should be designed in
such a way that ANYONE not familar with your organization or the nature of
the database can easily understand the object, tables, forms, whatnot and
what they do. So if you're working on a database where a table will store
information pertaining to Change Requests the 'tblChangeRequests' is a much
better choice than 'tblChnRqst'.
 
D

Dale Fye

Have you tried the DLOOKUP( ) function
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
M

mewins

Thanks, DLookup seems to be doing what I want. Also, I've kept my table
names short so as not to overload everything (as TAFDC stands for Temporary
Aid to Families with Dependent Children and that's just too long of a name
for a table :) ).
 
D

David H

Perchance, can you you fill us in on more of what the database is used for
the other object names? I have the suspicion that shorter table names are
possible (assuming that you're not too far along in development)

David H
 

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