B
Bandit
Hi,
I have a main form that has two combo boxes:
cboPlantform and that is used to filter the second combo
box cboCategories.
Based upon the plantform I populate the subform which
is called sfrmOptions.
That subform is really a table that has OptionID,
Option, Category, Area.
I don't want the user to have to type in the Category
and Area when they type in a new Option because it will be
the same as the previous record.
I either get error 91 or 2113 but I don't know hoe to
fix it. They throw and then stop and then throw again.
cboPlantform - unbound cboCategory -
unbound
sfrmOptions
code for main form
Private Sub cboCategory_AfterUpdate()
Dim mySQL_Cen As String
Dim mySQL_End As String
Dim mySQL_Mat As String
mySQL_Cen = "SELECT [tblOptions_Cen].[OptionID],
[tblOptions_Cen].[Option], [tblOptions_Cen].[Category],
[tblOptions_Cen].[Area] FROM tblOptions_Cen WHERE
((([tblOptions_Cen].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
mySQL_End = "SELECT [tblOptions_End].[OptionID],
[tblOptions_End].[Option], [tblOptions_End].[Category],
[tblOptions_End].[Area] FROM tblOptions_End WHERE
((([tblOptions_End].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
mySQL_Mat = "SELECT [tblOptions_Mat].[OptionID],
[tblOptions_Mat].[Option], [tblOptions_Mat].[Category],
[tblOptions_Mat].[Area] FROM tblOptions_Mat WHERE
((([tblOptions_Mat].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
If cboPlatform = "Centura" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_Cen].[Category] FROM tblOptions_Cen; "
Me![sfrmOptions].Form.RecordSource = mySQL_Cen
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
ElseIf cboPlatform = "Endura" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_End].[Category] FROM tblOptions_End; "
Me![sfrmOptions].Form.RecordSource = mySQL_End
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
ElseIf cboPlatform = "Mattson" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_Mat].[Category] FROM tblOptions_Mat; "
Me![sfrmOptions].Form.RecordSource = mySQL_Mat
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
Else
MsgBox "Please re-select a Platform.", vbOKOnly
End If
End Sub
Private Sub cboPlatform_AfterUpdate()
Me.sfrmOptions.Visible = False
Me.cboCategory.Requery
End Sub
Private Sub Form_Close()
DoCmd.OpenForm "Switchboard"
End Sub
Private Sub Form_Current()
Dim rs As Object
Set rs = Me.Recordset.Clone
If rs.EOF Or Not Me.NewRecord Then
' don't do anything if there's no records or it is
not a new record
Else
With rs
.MoveNext
Me![sfrmOptions].Form.[Category] = .Fields
("Category")
Me![sfrmOptions].Form.[Area] = .Fields
("Area")
End With
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.sfrmOptions.Visible = False
End Sub
code for sfrmOptions
Private Sub Form_Current()
Dim rs As Object
Set rs = Me.Recordset.Clone
If rs.EOF Or Not Me.NewRecord Then
' don't do anything if there's no records or it is
not a new record
Else
With rs
.MoveNext
Me![Category] = .Fields("Category")
Me![Area] = .Fields("Area")
End With
End If
End Sub
Anyone know how to correct this?
Thanks,
Bandit
I have a main form that has two combo boxes:
cboPlantform and that is used to filter the second combo
box cboCategories.
Based upon the plantform I populate the subform which
is called sfrmOptions.
That subform is really a table that has OptionID,
Option, Category, Area.
I don't want the user to have to type in the Category
and Area when they type in a new Option because it will be
the same as the previous record.
I either get error 91 or 2113 but I don't know hoe to
fix it. They throw and then stop and then throw again.
cboPlantform - unbound cboCategory -
unbound
sfrmOptions
code for main form
Private Sub cboCategory_AfterUpdate()
Dim mySQL_Cen As String
Dim mySQL_End As String
Dim mySQL_Mat As String
mySQL_Cen = "SELECT [tblOptions_Cen].[OptionID],
[tblOptions_Cen].[Option], [tblOptions_Cen].[Category],
[tblOptions_Cen].[Area] FROM tblOptions_Cen WHERE
((([tblOptions_Cen].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
mySQL_End = "SELECT [tblOptions_End].[OptionID],
[tblOptions_End].[Option], [tblOptions_End].[Category],
[tblOptions_End].[Area] FROM tblOptions_End WHERE
((([tblOptions_End].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
mySQL_Mat = "SELECT [tblOptions_Mat].[OptionID],
[tblOptions_Mat].[Option], [tblOptions_Mat].[Category],
[tblOptions_Mat].[Area] FROM tblOptions_Mat WHERE
((([tblOptions_Mat].[Category])=[Forms]![frmOptions]!
[cboCategory])); "
If cboPlatform = "Centura" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_Cen].[Category] FROM tblOptions_Cen; "
Me![sfrmOptions].Form.RecordSource = mySQL_Cen
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
ElseIf cboPlatform = "Endura" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_End].[Category] FROM tblOptions_End; "
Me![sfrmOptions].Form.RecordSource = mySQL_End
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
ElseIf cboPlatform = "Mattson" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_Mat].[Category] FROM tblOptions_Mat; "
Me![sfrmOptions].Form.RecordSource = mySQL_Mat
Me.sfrmOptions.Requery
Me.sfrmOptions.Visible = True
Else
MsgBox "Please re-select a Platform.", vbOKOnly
End If
End Sub
Private Sub cboPlatform_AfterUpdate()
Me.sfrmOptions.Visible = False
Me.cboCategory.Requery
End Sub
Private Sub Form_Close()
DoCmd.OpenForm "Switchboard"
End Sub
Private Sub Form_Current()
Dim rs As Object
Set rs = Me.Recordset.Clone
If rs.EOF Or Not Me.NewRecord Then
' don't do anything if there's no records or it is
not a new record
Else
With rs
.MoveNext
Me![sfrmOptions].Form.[Category] = .Fields
("Category")
Me![sfrmOptions].Form.[Area] = .Fields
("Area")
End With
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.sfrmOptions.Visible = False
End Sub
code for sfrmOptions
Private Sub Form_Current()
Dim rs As Object
Set rs = Me.Recordset.Clone
If rs.EOF Or Not Me.NewRecord Then
' don't do anything if there's no records or it is
not a new record
Else
With rs
.MoveNext
Me![Category] = .Fields("Category")
Me![Area] = .Fields("Area")
End With
End If
End Sub
Anyone know how to correct this?
Thanks,
Bandit