Hi,
I have a form(frmMain) with no controls. All empty. Inside the form, i have a sub form(frmSub). I am trying to open from another form(frmCustomers) the frmMain... Easy part... The hard one is to open with a WhereCondition for the frmSub according to the previous form.
I want to doubleclik Memo and check if YesNoData is TRUE or FALSE.
If it is FALSE, open the frmMain and add 10new rows where CustomersID is frmCustomers.CustomersID.
If it is TRUE, simple open frmMain with WhereCondition CustomersID = me.CustomersID...
Forms:
frmMain = > No controls
frmSub = > SubID,CustomersID, Data1, Data2
frmCustomers => CustomersID, Memo, YesNoData
Code:
Private Sub CustomersID_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "[Forms]![frmMain]![frmSub].Form.[CustomersID]=" & Me.CustomersID
If Me.YesNoData = FALSE Then
DoCmd.OpenForm "frmMain", , , , , Me!CustomersID
AddLines
Me.YesNo = "1"
'DoCmd.Close , "frmCustomers"
'DoCmd.Close , "frmMain"
'DoCmd.OpenForm "frmMain", , , stLinkCriteria
Else
'DoCmd.OpenForm "frmMain", , , stLinkCriteria
'DoCmd.Close , "frmCustomers"
End If
End Sub
Sub AddLines()
Dim i As Integer
Dim DefaultID As Long
DefaultID = Me.CustomersID
Forms!frmMain!frmSub.Form.AllowAdditions = True
For i = 1 To 10
DoCmd.GoToRecord , Forms!frmSubMain!frmSub.Form.CustomersID, acNewRec
Forms!frmMain!frmSub.Form.CustomersID= DefaultID
Next i
Forms!frmMain!frmSub.Form.AllowAdditions = False
End Sub
======================
I am getting an error 2489. I can't link to the sub form...
I test the code with not the frmMain... Simple frmSub and it was working great...
I added frmMain because i want to add later txt with sums from the frmSub...
Thank you very in advance.
:banghead::banghead::banghead:
I have a form(frmMain) with no controls. All empty. Inside the form, i have a sub form(frmSub). I am trying to open from another form(frmCustomers) the frmMain... Easy part... The hard one is to open with a WhereCondition for the frmSub according to the previous form.
I want to doubleclik Memo and check if YesNoData is TRUE or FALSE.
If it is FALSE, open the frmMain and add 10new rows where CustomersID is frmCustomers.CustomersID.
If it is TRUE, simple open frmMain with WhereCondition CustomersID = me.CustomersID...
Forms:
frmMain = > No controls
frmSub = > SubID,CustomersID, Data1, Data2
frmCustomers => CustomersID, Memo, YesNoData
Code:
Private Sub CustomersID_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
stLinkCriteria = "[Forms]![frmMain]![frmSub].Form.[CustomersID]=" & Me.CustomersID
If Me.YesNoData = FALSE Then
DoCmd.OpenForm "frmMain", , , , , Me!CustomersID
AddLines
Me.YesNo = "1"
'DoCmd.Close , "frmCustomers"
'DoCmd.Close , "frmMain"
'DoCmd.OpenForm "frmMain", , , stLinkCriteria
Else
'DoCmd.OpenForm "frmMain", , , stLinkCriteria
'DoCmd.Close , "frmCustomers"
End If
End Sub
Sub AddLines()
Dim i As Integer
Dim DefaultID As Long
DefaultID = Me.CustomersID
Forms!frmMain!frmSub.Form.AllowAdditions = True
For i = 1 To 10
DoCmd.GoToRecord , Forms!frmSubMain!frmSub.Form.CustomersID, acNewRec
Forms!frmMain!frmSub.Form.CustomersID= DefaultID
Next i
Forms!frmMain!frmSub.Form.AllowAdditions = False
End Sub
======================
I am getting an error 2489. I can't link to the sub form...
I test the code with not the frmMain... Simple frmSub and it was working great...
I added frmMain because i want to add later txt with sums from the frmSub...
Thank you very in advance.
:banghead::banghead::banghead: