Returned results are incorrect using a form containing a sub-form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using the wizard, I created a form which contains a sub-form (based on two
related tables using an indexed foreign key).

1) Table A contains "ORDER header" information
2) Table B contains "ORDER details" information. That is to say, for every
entry in table A (i.e. ORDER number) there are many entries in table B.

However, when I run a macro to:

1) Open the form (i.e. table A)
2) obtain the last record for the form (i.e. the latest of table A)

I get the first record for the form (i.e. table A)

AND in the sub-form, the cursor lies on the last record for the set of
records for the above.

Any idea as to what is going on and how to remedy this? Your help is greatly
appreciated.
 
Herbert,

I must have missed something because from your description looks as
though it is all operating normally

Can you describe the problem please

Brett

Using the wizard, I created a form which contains a sub-form (based on two
related tables using an indexed foreign key).

1) Table A contains "ORDER header" information
2) Table B contains "ORDER details" information. That is to say, for every
entry in table A (i.e. ORDER number) there are many entries in table B.

However, when I run a macro to:

1) Open the form (i.e. table A)
2) obtain the last record for the form (i.e. the latest of table A)

I get the first record for the form (i.e. table A)

AND in the sub-form, the cursor lies on the last record for the set of
records for the above.

Any idea as to what is going on and how to remedy this? Your help is greatly
appreciated.

Cheers,
Brett
 
Hi Brett,

Thank you for the response. May be things will be more clear if I use an
example. Let us suppose I have the following order numbers in table A (i.e.
the order header)

Order Nos. 60
120
1234
1122

And the following order details in table B:

Order No 60 detail line 1
Detail line 2
Detail line 3

Order No 120 detail line 1

Order No 1234 detail line 1
Detail line 2

Order No 1122 has just been created and no detail exists as of yet.

I run a macro to open the form to get the latest order no and the
corresponding details lines

Instead of getting order 1122 and the detail lines (i.e. the sub-form) being
empty, I get info about order number 60 (i.e. the very first) and all its
related detail lines.

I hope this illustrates the problem I am having.

I'd like to add that I have a number of extra fields (for DISPLAY purposes
ONLY) on the form which carry totals and sub-totals obtained from the
sub-form. Could this have a bearing on the behavior of the form?

Thank you

Herbert
 
Thank you all. I have cleared the problem. How? I basically re-created the
form / sub-form. But this time round, I kept all the key fields and simply
made them un-visible. that seems to work. I now get the right info. Thanks to
anyone who particiated.
 
Back
Top