Q. How do I synch main form and pop up form ?

  • Thread starter Thread starter Jim Jones
  • Start date Start date
J

Jim Jones

Hi,

I know I've asked this before, but it seems each scenario is
different.

I can't figure out what the simplest way is to synchronize the main
form to a pop up form.

I cannot find what I need on either www.rogersaccesslibray.com or on
www.mvps.com/access

If you know of a site where synchronizing main and pop up form is
located, please tell me.

Now, the Access wizard which attempts to create a form based on
multiple tables in a query does this, but I'm baffled at the code they
use.

Please point me to a far simpler method, which I believe should only
need something to the effect of:

* * * * * * * * * * * * * *
Command button code:

Open the pop up form to the related record on the main form.

When advancing through the records on the main form, advance also
the related records (customer number), on the pop up form.

** * * * * * * * * * * * * *

Your help is always appreciated,

Jim
 
DoCmd.OpenForm "NameOfPopUpForm",,,"[PKNameOnPopUpForm] = " &
Me!PKNameOnMainForm


I'm sorry, that doesnt synchronize my main form with my pop up form.
The code you prescribed basically does the same thing mine does, which
is commented out.

Please see:


Private Sub cmdCustomerDataNotes_Click()
On Error GoTo Err_cmdCustomerDataNotes_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerNotesqry"

' stLinkCriteria = "[CustomerNumber]=" & Me![Customer_Number]
' DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria

DoCmd.OpenForm "frmCustomerNotesqry", , , "[CustomerNumber] = " &
Me![Customer_Number]

Exit_cmdCustomerDataNotes_Click:
Exit Sub

Err_cmdCustomerDataNotes_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerDataNotes_Click

End Sub



Should there be a requery statement somewhere, in all that to move the
pop up form to the presently displayed record ?

Thanks,
Jim
 
That method would only work for the first time.

I would open the PopUp form with navigation disabled.
But, the recordset needs to have all the records on the
main form.

docmd.OpenForm "PKNameOnMainForm",,,,,,"PKFieldName"

That will pass in the name of the field we want to open
the form to the OpenArgs property of the form. The
commented out Me.Filter line is incase the Key field is a
text field.

Private Sub Form_Open()
If Me.OpenArgs <> "" Then
Me.Filter = "PKFieldName=" & Me.OpenArgs
'Me.Filter = "PKFieldName='" & Me.OpenArgs & "'"
Me.FilterOn = True
End If
End Sub


Okay, that will open the form to the right record, and
jump to it. Now, you need to sync the main form. On the
OnCurrent event of the main form:


Private Sub OnCurrent()
If IsLoaded("PopupForm") Then
Forms("PopupFOrm").Filter = "PKFieldName=" &
Me.txtPKField
'Forms("PopupFOrm").Filter = "PKFieldName='" &
Me.txtPKField & "'"

Forms("PopupFOrm").FilterOn= True
End If
End Sub
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view
or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName)
<> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView
Then
IsLoaded = True
End If
End If

End Function


Chris




-----Original Message-----
DoCmd.OpenForm "NameOfPopUpForm",,,"[PKNameOnPopUpForm] = " &
Me!PKNameOnMainForm


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Hi,

I know I've asked this before, but it seems each scenario is
different.

I can't figure out what the simplest way is to synchronize the main
form to a pop up form.

I cannot find what I need on either www.rogersaccesslibray.com or on
www.mvps.com/access

If you know of a site where synchronizing main and pop up form is
located, please tell me.

Now, the Access wizard which attempts to create a form based on
multiple tables in a query does this, but I'm baffled at the code they
use.

Please point me to a far simpler method, which I believe should only
need something to the effect of:

* * * * * * * * * * * * * *
Command button code:

Open the pop up form to the related record on the main form.

When advancing through the records on the main form, advance also
the related records (customer number), on the pop up form.

** * * * * * * * * * * * * *

Your help is always appreciated,

Jim


.
 
Jim said:
DoCmd.OpenForm "NameOfPopUpForm",,,"[PKNameOnPopUpForm] = " &
Me!PKNameOnMainForm


I'm sorry, that doesnt synchronize my main form with my pop up form.
The code you prescribed basically does the same thing mine does, which
is commented out.

Please see:


Private Sub cmdCustomerDataNotes_Click()
On Error GoTo Err_cmdCustomerDataNotes_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerNotesqry"

' stLinkCriteria = "[CustomerNumber]=" & Me![Customer_Number]
' DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria

DoCmd.OpenForm "frmCustomerNotesqry", , , "[CustomerNumber] = " &
Me![Customer_Number]

Exit_cmdCustomerDataNotes_Click:
Exit Sub

Err_cmdCustomerDataNotes_Click:
MsgBox Err.Description
Resume Exit_cmdCustomerDataNotes_Click

End Sub



Should there be a requery statement somewhere, in all that to move the
pop up form to the presently displayed record ?


The stLinkCriteria will open the other form to the proper
record, but it won't do anything to keep the two forms in
sync.

I suggest that you change the popup form's record source
query to use the criteria:
Forms!yourmainform.Customer_Number
under the CustomerNumber field.

Then you don't need to use the stLinkCriteria when you open
the popup form. Add the line:
Forms!frmCustomerNotesqry.Requery
to yourmainform's Current event, to sybchronize the popup
form as you navigate through the records in the main form.
 
Jim Jones said:
Hi,

I know I've asked this before, but it seems each scenario is
different.

I can't figure out what the simplest way is to synchronize the main
form to a pop up form.

I cannot find what I need on either www.rogersaccesslibray.com or on
www.mvps.com/access

If you know of a site where synchronizing main and pop up form is
located, please tell me.

Now, the Access wizard which attempts to create a form based on
multiple tables in a query does this, but I'm baffled at the code they
use.

Please point me to a far simpler method, which I believe should only
need something to the effect of:

* * * * * * * * * * * * * *
Command button code:

Open the pop up form to the related record on the main form.

When advancing through the records on the main form, advance also
the related records (customer number), on the pop up form.

** * * * * * * * * * * * * *

Your help is always appreciated,

But this is exactly what that wizard-generated code does! I'm not sure
why you don't want to use it. Is it that you've already created the
forms you want to have behave this way, and don't see how to copy the
wizard's code for the existing forms?
 
I suggest that you change the popup form's record source
query to use the criteria:
Forms!yourmainform.Customer_Number
under the CustomerNumber field.

Then you don't need to use the stLinkCriteria when you open
the popup form. Add the line:
Forms!frmCustomerNotesqry.Requery
to yourmainform's Current event, to sybchronize the popup
form as you navigate through the records in the main form.

Good suggestion Marshall. This is much easier than trying to use the
current event on the main form to "force" populate existing fields on
the popup form with the correct values.


-D
 
Back
Top