how do I synchronize 2 forms?

G

Guest

I have 2 forms, both based on the same table (BillPtTbl). In this table are
demographics like last name, first name, DOB, address, telephone, etc.
The "main" form (BillPtFrm) is the central form of the database with many
subforms to it.
The second form (BillPtPopFrm) is as stated above based on BillPtTbl also.
It is intended to be a popup form, to help populate the main form. I have a
button on the main form that is hyperlinked to the popup form.
What I want is to click the button --> the popup form comes up --> I enter
the new data --> hit a refresh/save/update button and it then populates that
info (last name, first name, DOB) on the main form. I then can close the
popup form and return to the main form.
My problem is the info on the popup form is not getting updated on the main
form.
Please advise.
BTW, the reason I want to use the popup form and not enter directly into the
main form is that the popup form has much more info (e.g. SS#, address,
telephone, etc.) that I don't want on the main form. I just want the name
and DOB to be updated/transferred to the main form.
 
G

Guest

Hi dlazenby,

If your popup form and main form are both bound to the same data source (ie:
same table), then simply updating the information on your popup form and
saving it should cause the main form to be updated. To force a refresh, you
could call forms!MAINFORMNAME.refresh as your popup closes.

Hope this helps.

Damian.
 
G

Guest

That didn't work. I am not sure why it doesn't track/update. I don't know if
it has to do with it being popup or what.
Any other thoughts?
 
G

Guest

If you move to a different record and back again does it update (on your main
form)?

D.
 
G

Guest

Thanks for your additional response. No, it doesn't really update in the way
that I need it to.
I think it is more than a refresh issue command, because I don't know how
the main form would know that it should have the current popup form data.
Again, it is like having 2 forms based on the same table but focusing on
different fields. The base table has 10 demographic fields-name, DOB, SS#,
etc. The popup form has on it those 10 demographic fields. The main form only
wants/needs 3 fields- last name, first name, DOB. (It has many subforms
attached to it.)
The user would start off with the demographic form, fill it out and then go
to the main form. My problem is that when I go to the main form, those name
and DOB fields are not what I just entered on the demographic form.
I think I need VB code to 1) save that record just entered on the popup form
2) transmit/pass that to the main form and 3) refresh the main form so that
the field data that was sent is now on the main form.
A. I don't know what code to use.
B. I don't know if that button should be on the popup form or the main form
or both.
Please advise.
Again, thanks for your help.
 
G

Guest

So what you are saying is that your popup form is ADDING a NEW record that
you want to then have the main form focus on.

You would need to requery the new form, then move to the appropriate record,
like this:

forms!FORMNAME.requery
forms!FORMNAME.recordsetclone.findfirst "ID = " & me.lngID
forms!FORMNAME.recordset.bookmark = forms!FORMNAME.recordsetclone.bookmark

Use the above code in the close button on click event of your popup form.

Damian.
 
D

daniel

I have almost the same situation as you and here is how I made it work:

Add a button to your first Form to open the popup frm.

example:

******************
'this comes from the OpenForm Button wizard

Private Sub cmdOpenPop_Click()
On Error GoTo Err_cmdOpenPop_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerPopup"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenPop_Click:
Exit Sub

Err_cmdOpenPop_Click:
MsgBox"Error from Open Pop Form" 'Err.Description
Resume Exit_cmdOpenPop_Click

End Sub
*******************

you need to have the CustomerID (your ID) on both Forms so they
connect to the same ID and Name.

on the (popup) form in the last field, in which you have to type in new
data,
before you close the form, do:

Properties, Event, AfterUpdate, Codebuilder,
then just copy the DoCmd code into the AfterUpdate.

Private Sub Form_AfterUpdate()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub

now, when you type in data in that last field and then press enter, the data
in
the popup form and in the first form is updated.
but you have to press Enter so the cursor will go to the next part which
then might
be the Close button.

(no refresh or requery needed. if you do a requery, the data in your first
form will
go to the first record and you don't want that).

I have 4 Checkboxes in the first form which I update (in AfterUpdate) with
this line:
Application.RunCommand acCmdSaveRecord
this updates the data for my second form. you can also add this line to the
other 2 lines.
you can also try just this line instead the other two. whichever works, as
long it works.

hope that helps some.
 
G

Guest

Damian,
Thanks for your reply. I have been away a few days. I am trying to implement
your code, but still not quite there.
I have set up a bare-bones test table and 2 test forms to try to use your
code.
The table (TestTbl) has 3 fields- TestIDpk (primary key), lastname, and
firstname. The 2 forms are TestFrmMain and TestFrmPop, both based (record
source) on TestTbl.
Again, what I am trying to achieve with my forms:
TestFrmMain is the main form (with many subforms), I would have a button or
hyperlink on TestFrmMain that connects me to TestFrmPop (pop up form). I then
fill out all the fields on the popup form. I then click a button to
"pass/transfer" that data back to the main form so that I now have the
correct name on the main form.
Regarding, your suggested code,

forms!FORMNAME.requery
forms!FORMNAME.recordsetclone.findfirst "ID = " & me.lngID
forms!FORMNAME.recordset.bookmark = forms!FORMNAME.recordsetclone.bookmark

this is how I tried to implement it (event proced

Private Sub Form_Close()
Forms!TestFrmPop.Requery
Forms!TestFrmPop.RecordsetClone.FindFirst "TestIDpk = " & Me.TestIDpk
Forms!TestFrmPop.Recordset.Bookmark = Forms!TestFrmPop.RecordsetClone.Bookmark

End Sub

Please advise. Thanks again.
 

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