Synchronize subforms with forms

F

Fred

I have a form (frmMain) based off table 1.
On this form is a button which opens up another form (frmSub) also based off
table 1.
I do this to reduce the clutter when entering data.

When I open up frmSub for a new record, and I check the primary key (PK),
they aren't the same!!!
It is usually advanced by one.

If the data exists, it works fine...its only on new data.

I synchronized the two forms by using the Wizard when I created the button
to open up frmSub.

Any help is greatly appreciated.

TIA
 
P

Paul Overway

What you are describing isn't a subform....it is another form. And the
behavior you've observed should be expected because you're entering a new
record on both forms. You should use tabs and REAL subforms to organize you
data.
 
F

Fred

I actually tried that at first where they were split up into 2 tables but
with a 1 to 1 relationship based on pkid.
It worked fine with the data already in there opening up the subform with
"pkid = " & Me![pkid] .
But with new data, when I open it up with the control button, its pkid was
not synchronized with the main form because it did not exist.

I figured a way around this by forcing the form to go back one record and
then back to the current record before opening up the "subform". This
forced the new record to get updated. But there's got to be an easier more
logical way.

Thanks
 
P

Paul Overway

Yeah...the easier/more logical way is how I suggested. Based on your
description, you probably don't need subforms at all....just tabs. Nor is
there any reason to put the data in separate tables. It sounds like you're
bent on covering up a bad design with spaghetti logic.

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


Fred said:
I actually tried that at first where they were split up into 2 tables but
with a 1 to 1 relationship based on pkid.
It worked fine with the data already in there opening up the subform with
"pkid = " & Me![pkid] .
But with new data, when I open it up with the control button, its pkid was
not synchronized with the main form because it did not exist.

I figured a way around this by forcing the form to go back one record and
then back to the current record before opening up the "subform". This
forced the new record to get updated. But there's got to be an easier
more
logical way.

Thanks

Paul Overway said:
What you are describing isn't a subform....it is another form. And the
behavior you've observed should be expected because you're entering a new
record on both forms. You should use tabs and REAL subforms to organize you
data.
 
A

Albert D. Kallal

I figured a way around this by forcing the form to go back one record and
then back to the current record before opening up the "subform". This
forced the new record to get updated. But there's got to be an easier
more
logical way.

The above simply means you want to force a disk write before you open the
2nd form? So, it seems your real question is how do I force a disk write. (I
mean, moving off the record, and moving back simply means the record gets
written to disk).

Just place the following code at the start of your routine:

me.Refresh

The above will force a disk write, and all should be well.
 

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