problem with a popup form opened by another popup form

fabrizio19

Registered User.
Local time
Today, 02:50
Joined
Aug 9, 2012
Messages
75
Hi All,
I have 3 single form. The first one is named cath lab, the second one is IABP (popup form), the third is another popup form named Complicanze device.
From the cathlab form there is a click button named IABP that open the popup form IABP. In the IABP form there is another click button named complicanza.
On the click event for the button complicanze I inserted the following code:
Private Sub Complicanze_Device_Click()
On Error GoTo Err_Complicanze_Device_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Complicanze Device"
stLinkCriteria = "PTS=" & Me.PTS
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, acDialog, Me.PTS & "|" & Me.Ablazione_TV_N & "|" & Me.Inserimento_IABP_N
Exit_Complicanze_Device_Click:
Exit Sub
Err_Complicanze_Device_Click:
MsgBox Err.Description
Resume Exit_Complicanze_Device_Click

End Sub

On the load form event I put the code:

Private Sub Form_Load()
If MsgBox("Nuova complicanza?", vbYesNo + vbDefaultButton2) = vbYes Then
If Me.Dirty = True Then Me.Dirty = False
DoCmd.GoToRecord , , acNewRec
Dim aryArgs As Variant
aryArgs = Split(Me.OpenArgs, "|")
Me.PTS.Value = aryArgs(0)
Me.Ablazione_TV_N.Value = aryArgs(1)
Me.Inserimento_IABP_N.Value = aryArgs(2)
Me.[Complicanza N].Value = Nz(DMax("[Complicanza N]", "Complicanze device", "[PTS]=" & Me.PTS & "And [Ablazione TV N]=" & Me.Ablazione_TV_N & "And [Inserimento IABP N]=" & Me.Inserimento_IABP_N), 0) + 1
Else
DoCmd.GoToRecord , , acLast
End If
End Sub

The problem is: when the IABP form is no a popup form every thing works well.
When the IABP is a popup form it happens that a new record is inserted in the IABP popup form instead of Complicanze device popup form!Moreover in no new record are added in the form Complicanze device but I can only edit the record!
Why it happens?
Please help me.
f
 
I'm not sure why it needs to be a pop up if you're opening as a dialog.

But anyway I expect the reason will be because the line

DoCmd.GoToRecord , , acNewRec

isn't specifying a form so you're letting access decide and it seems if it's set to pop up it decides the wrong form.

DoCmd.GoToRecord acDataForm, "Complicanze Device", acNewRec

Would fix that behaviour I think.
 
Got it!
Great it works perfectly
Thank you very much!
 

Users who are viewing this thread

Back
Top Bottom