MajP and John,
Thank you for your help. MajP I think my code is written similar to your code, but I'm getting an error. Thanks for letting me know where I'm going wrong.
Here is the code:
Public frmNewform As Form
Private Sub txtBusName_DblClick(Cancel As Integer)
Dim strSQL As String
Dim rst1 As New ADODB.Recordset
Set frmNewform = New Form_frmProspecting
intInstanceNum = intInstanceNum + 1
strSQL = "Select * from CHAPMAN_NATIONWIDE WHERE [No]
= " & Me.txtNo & ";"
Debug.Print "frmProspectingResults | The recordsource
for the form instance is: " & strSQL
frmNewform.RecordSource = strSQL
EntityNo = Me.txtNo
Debug.Print "frmProspectingResults | Passing No: " & Me.txtNo & " to frmProspecting instance"
frmNewform.SetFocus
frmNewform.txtNo.Value = Me.txtNo
Debug.Print "txtNo of frmProspecting instance = " & frmNewform.txtNo.Value
frmNewform.Caption = Me.txtBusName & ": " & intInstanceNum
clnClient.Add Item:=frmNewform, Key:=CStr(frmNewform.hWnd)
End Sub
=====
Here is the code that gets fired when the form instance is opened:
Private Sub Form_Open(Cancel As Integer)
Dim strSQL As String
Dim rst1 As New ADODB.Recordset
Me.Requery
Debug.Print "frmProspecting " & Me.txtNo & ", " & Me.txtBusName & ", " & Me.RecordSource
EntityNo = Me.txtNo (I GET AN ERROR HERE BECAUSE Me.txtNo IS NULL; ENTITYNO IS A PUBLIC VARIABLE)
Debug.Print "frmProspecting instance initial EntityNo = " & EntityNo
strSQL = "SELECT CHAPMAN_NATIONWIDE.[No] FROM (CHAPMAN_NATIONWIDE " & _
" INNER JOIN tblComments ON CHAPMAN_NATIONWIDE.[No] = tblComments.[No]) INNER JOIN " & _
" tblDealProgress ON tblComments.intSeq = tblDealProgress.intSeq WHERE (((CHAPMAN_NATIONWIDE.[No])= " & Me.txtNo & "));"
Debug.Print "frmProspecting | check for deal: " & strSQL
rst1.ActiveConnection = CurrentProject.Connection
rst1.open strSQL, , adOpenKeyset, adLockOptimistic
If rst1.EOF Then
Me.cboLevel.Enabled = False
Me.cboInterested.Enabled = False
Else
Me.cboLevel.Enabled = True
Me.cboInterested.Enabled = True
End If
rst1.Close
End Sub
John