Adding Record in form - Related Data from related tbl doesn't show

W

Whitey

Hi,
I have tblTenantInfo related to tblRentPayments as a one to many on UnitID
field. The form I created to enter rent payments has FirstName and LastName
fields from tblTenantInfo on it and when I enter a unit # in UnitID field of
tblRentInfo the first and last Names show up automatically from
tblTenantInfo, which is what I want so I have a visual check that the rent is
going to the correct tenant.
Problem - I created another form to enter and update current rent amount. I
have tblTenantInfo related to tblLeaseCharges as a one to one on UnitID
field. Obviously, each tenant only has one rent amount but the rent can
increase. When I enter a unit # in UnitID field of tblLeaseCharges the
related first and last name fields from tblTenantInfo remain blank. How can I
get the First and Last fields to show up automatically like they due in the
1st form I created?

Thanks for any reply - I am a self taught novice.
 
J

June7

How are you accomplishing the display of tenant info on the first form? Code
in Update Event of Unit# textbox? Sounds like the second form would duplicate
this event. VBA code or macros?
 
W

Whitey

All I did was drag the fields onto the blank form from tblLeaseCharges and
tbl TenantInfo. I had did the same thing with tblRentInfo and tblTenantInfo
which works. Access created the underlying SQL code which is similar in both
forms. Neither forms have any VBA nor macros in the event tab.
 
J

June7

No code or macros for the form but what about the objects on the form? I
don't see how there could not be for the first form. If the UnitID entry box
is bound to field in the table then entering a value should just change what
is in the table, not force the form to find and display related info. For
this you would need an unbound box with code/macro in its Update event
(actually some other events would also serve but this is simplest) which
would execute a filter of the recordset or requery the form's recordsource or
in the case of a new record automatically set the values of fields. With that
in mind, what is not happening on the new form makes more sense to me.
 
W

Whitey via AccessMonster.com

There is no code or macros in any of the objects on the form except for a
combo box which opens a report. I played around with everything, changing
field settings, (setting them exactly the same as the form that works),
changing the form settings to the same as well. Finally, the only thing that
worked was to change the relationship from one to one to one to many which
necessitated changing the Primary Key to my Autonumber field RentID and
UnitID attribute Index to Yes(Duplicates OK). Now when entering a new record,
I enter a Unit # into UnitID field which is bound to tblLeaseCharges and both
first and last names fields populate from tblTenantInfo which they are bound
to. Problem is that a unit can have only one rent amount, so if I enter a
unit # twice both rent amounts will be stored in the table in 2 separates
records. So I guess my question now is why don't the fields populate with a
one to one relationship. Also I'm sure there is code to check if this happens
but being a novice I haven't a clue how to write it or where to put it. I
also don't have a table with only valid unit numbers in it to check against
which I probably should but not sure how to do the checking.
Thanks for your help June7
No code or macros for the form but what about the objects on the form? I
don't see how there could not be for the first form. If the UnitID entry box
is bound to field in the table then entering a value should just change what
is in the table, not force the form to find and display related info. For
this you would need an unbound box with code/macro in its Update event
(actually some other events would also serve but this is simplest) which
would execute a filter of the recordset or requery the form's recordsource or
in the case of a new record automatically set the values of fields. With that
in mind, what is not happening on the new form makes more sense to me.
All I did was drag the fields onto the blank form from tblLeaseCharges and
tbl TenantInfo. I had did the same thing with tblRentInfo and tblTenantInfo
[quoted text clipped - 21 lines]
 
J

June7

W, Think the only way I could be of any help is to get my eyes and hands on
your project. If you want to try attaching the project in a zip folder to a
personal message or PM me with an email address I can respond to.
 
J

June7

Ooops, guess can't PM in this site. What the heck, my email is
(e-mail address removed).
 

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