Reference Subform

  • Thread starter Thread starter Bandit
  • Start date Start date
B

Bandit

Hi,
I am automating the data input of a couple items in a
subform. It rund fine by itself but errors when I tie it
into a form that I use as a filter. The mainform and
subform have no data linkage items

Pick Category...
Pick Area...

Subform pops up with the correct form that needs to be
populated


This is what is in the main form which has to fields that
are used as filters

//////
Private Sub cboPlatform_AfterUpdate()
If cboPlatform = "Cents" Then
Me.cboCategory.RowSource = "SELECT DISTINCT
[tblOptions_Cen].[Category] FROM tblOptions_Cen; "
Me.sfrmOptions.SourceObject = "sfrmOptions_Cen"
Me.cboCategory.Requery
Else
'other stuff
end if
/////////

This is what is in the subform and it runs fine
independendly of the mainform

//////
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
//////

When I run the mainform with the subform coded this is
what is thrown...
when adding a record it gives me error '2113'value not
valid for this field...
and it highlights
Me![Category] = .Fields("Category") 'this is in the
subform


Anyone know how to fix this? And why?

Thanks,
Bandit
 
Hi

The proper reference to the subform would be as follows:

[forms]![MainFormName]![SubformName].Form!ControlToReferenceOnSubForm

Maurice
 
Back
Top