Disappearing New Form

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

Guest

Hi All

I can't work out why this code doesn't work:

Private Sub List0_DblClick(Cancel As Integer)
Dim strSQL As String
Dim frmS As Form

strSQL = "SELECT tblBOMSOs.*, tblBOMSOLines.* " _
& "FROM tblBOMSOs INNER JOIN tblBOMSOLines " _
& "ON tblBOMSOs.BOMSOID = tblBOMSOLines.BOMSOID " _
& "WHERE tblBOMSOs.BOMSOID = " & Me.List0.Value
Me.Visible = False
Set frmS = New Form_frmSOEntryTEST
With frmS
.RecordSource = strSQL
.Visible = True
End With
End Sub

The new form (pop-up, modal)appears for a brief moment, then vanishes. I
tried stripping all the code out of the form's module, but no difference in
behaviour.

Any suggestions?

Thank you.

AliKwok
 
AliKwok said:
Hi All

I can't work out why this code doesn't work:

Private Sub List0_DblClick(Cancel As Integer)
Dim strSQL As String
Dim frmS As Form

strSQL = "SELECT tblBOMSOs.*, tblBOMSOLines.* " _
& "FROM tblBOMSOs INNER JOIN tblBOMSOLines " _
& "ON tblBOMSOs.BOMSOID = tblBOMSOLines.BOMSOID " _
& "WHERE tblBOMSOs.BOMSOID = " & Me.List0.Value
Me.Visible = False
Set frmS = New Form_frmSOEntryTEST
With frmS
.RecordSource = strSQL
.Visible = True
End With
End Sub

The new form (pop-up, modal)appears for a brief moment, then vanishes. I
tried stripping all the code out of the form's module, but no difference in
behaviour.

Any suggestions?

Thank you.

AliKwok

frmS is a local variable. It disappears (goes out of scope when the Sub
ends). So the reference to the new form disappears, and the form becomes
garbage. You need to make frmS a static variable defined outside the sub
 
Back
Top