A
Arvi Laanemets
Hi
I have a continous form, where amongst another controls are 2 combos. The
RecordSource for second combo depends on selection in first one. Settings
below work, until the form is inserted as subform.
Form fmForm:
Name="fmForm"
RecordSource=tblTable1
Private Sub Form_Current()
If Nz(Me!cbbCombo2) = 0 Then
Me!cbbCombo1.Enabled = True
Me!cbbCombo1.SetFocus
Else
Me!cbbCombo1.Enabled = False
End If
End Sub
Private Sub cbbCombo2_GotFocus()
If Nz(Me!cbbCombo1) = 0 Then
MsgBox ("Vali sõidugrupp!")
Me!cbbCombo1.Enabled = True
Me!cbbCombo1.SetFocus
Exit Sub
End If
Me!cbbCombo2.Requery
End Sub
cbbCombo1:
Name=cbbCombo1
ColumnCount=2
ControlSource=Reg1ID
RowSourceType=Table/Query
RowSource=SELECT [tblRegistry1].[Reg1ID], [tblRegistry1].[Reg1Name] FROM
tblRegistry1;
BoundColumn=1
Enabled=No
cbbCombo2:
Name=cbbCombo2
ColumnCount=2
ControlSource=Reg2ID
RowSourceType=Table/Query
RowSource=SELECT DISTINCT [tblRegistry2].[Reg2ID],
[tblRegistry2].[Reg2Name] FROM tblRegistry2 WHERE
((([tblRegistry1].[Reg1ID])=[Forms]![fmForm]![cbbCombo1]));
BoundColumn=1
Enabled=Yes
I used a form like this as subform before - only adjustments needed, were:
Form fmMainForm:
Name="fmMainForm"
Form fmForm:
...
Private Sub cbbCombo2_GotFocus()
...
Forms!fmMainForm!fmForm!cbbCombo2.Requery
End Sub
cbbCombo2:
...
RowSource=SELECT DISTINCT [tblRegistry2].[Reg2ID],
[tblRegistry2].[Reg2Name] FROM tblRegistry2 WHERE
((([tblRegistry1].[Reg1ID])=[Forms]![fmMainForm]![fmForm]![cbbCombo1]));
Now I tried to use same design for another project, but it doesn't work
there. Both main forms are multitab forms. The only difference - in new
project the main form doesn't have data source - on every tab is inserted an
independent subform with his own datasource (like a switchboard, but with
tabs instead of buttons calling forms). And when debbugging the code, I
can't refer to main form somehow at all.
Ons same subform (fmForm) I have another control - a calculated TextBox.
txtText:
ControlSource =DLookUp("[SomeField]";"[tblRegistry3]";"[Reg3ID]=" &
[Forms]![fmForm]![txtReg3ID])
When the form is used as subform on fmMainForm, this field returns an error
too - althoughe the ControlSource is edited:
ControlSource =DLookUp("[SomeField]";"[tblRegistry3]";"[Reg3ID]=" &
[Forms]![fmMainForm]![fmForm]![txtReg3ID])
I hope someone gives some help!
Thanks in advance
Arvi Laanemets
I have a continous form, where amongst another controls are 2 combos. The
RecordSource for second combo depends on selection in first one. Settings
below work, until the form is inserted as subform.
Form fmForm:
Name="fmForm"
RecordSource=tblTable1
Private Sub Form_Current()
If Nz(Me!cbbCombo2) = 0 Then
Me!cbbCombo1.Enabled = True
Me!cbbCombo1.SetFocus
Else
Me!cbbCombo1.Enabled = False
End If
End Sub
Private Sub cbbCombo2_GotFocus()
If Nz(Me!cbbCombo1) = 0 Then
MsgBox ("Vali sõidugrupp!")
Me!cbbCombo1.Enabled = True
Me!cbbCombo1.SetFocus
Exit Sub
End If
Me!cbbCombo2.Requery
End Sub
cbbCombo1:
Name=cbbCombo1
ColumnCount=2
ControlSource=Reg1ID
RowSourceType=Table/Query
RowSource=SELECT [tblRegistry1].[Reg1ID], [tblRegistry1].[Reg1Name] FROM
tblRegistry1;
BoundColumn=1
Enabled=No
cbbCombo2:
Name=cbbCombo2
ColumnCount=2
ControlSource=Reg2ID
RowSourceType=Table/Query
RowSource=SELECT DISTINCT [tblRegistry2].[Reg2ID],
[tblRegistry2].[Reg2Name] FROM tblRegistry2 WHERE
((([tblRegistry1].[Reg1ID])=[Forms]![fmForm]![cbbCombo1]));
BoundColumn=1
Enabled=Yes
I used a form like this as subform before - only adjustments needed, were:
Form fmMainForm:
Name="fmMainForm"
Form fmForm:
...
Private Sub cbbCombo2_GotFocus()
...
Forms!fmMainForm!fmForm!cbbCombo2.Requery
End Sub
cbbCombo2:
...
RowSource=SELECT DISTINCT [tblRegistry2].[Reg2ID],
[tblRegistry2].[Reg2Name] FROM tblRegistry2 WHERE
((([tblRegistry1].[Reg1ID])=[Forms]![fmMainForm]![fmForm]![cbbCombo1]));
Now I tried to use same design for another project, but it doesn't work
there. Both main forms are multitab forms. The only difference - in new
project the main form doesn't have data source - on every tab is inserted an
independent subform with his own datasource (like a switchboard, but with
tabs instead of buttons calling forms). And when debbugging the code, I
can't refer to main form somehow at all.
Ons same subform (fmForm) I have another control - a calculated TextBox.
txtText:
ControlSource =DLookUp("[SomeField]";"[tblRegistry3]";"[Reg3ID]=" &
[Forms]![fmForm]![txtReg3ID])
When the form is used as subform on fmMainForm, this field returns an error
too - althoughe the ControlSource is edited:
ControlSource =DLookUp("[SomeField]";"[tblRegistry3]";"[Reg3ID]=" &
[Forms]![fmMainForm]![fmForm]![txtReg3ID])
I hope someone gives some help!
Thanks in advance
Arvi Laanemets