updating a yes/now field from main form with after update

  • Thread starter Thread starter Brian Goldhammer via AccessMonster.com
  • Start date Start date
B

Brian Goldhammer via AccessMonster.com

I have a field in my main form that is a combo box with "Original" and
"Credit Adjustment" as the options. When "Credit Adjustment" (default value
is CA) is selected, i would like the yes/no field in the subform for "Credit
Adjustment" to be set as yes (True).

I have this After Update procedure already in place and would like to add the
above function but I am lost on finding how to write the code.
*******************************************
Private Sub Combo69_AfterUpdate()
If Combo69.Value = "CA" Then
Label39.ForeColor = 255
Else: Label39.ForeColor = 0

End If
End Sub
*******************************************
Thanks in advance,
 
I have a field in my main form that is a combo box with "Original" and
"Credit Adjustment" as the options. When "Credit Adjustment" (default value
is CA) is selected, i would like the yes/no field in the subform for "Credit
Adjustment" to be set as yes (True).

The (logical) problem here is that typically a subform might have
zero, one, or any number of records related to the mainform record. So
there isn't "a" yes/no field in the subform - there might be 22,841 of
them!

What is the recordsource of the subform? Do you want to update only
the currently selected subform record? If so use

Me.Subformname.Form![Credit Adjustment] = True

using the Name property of the subform.

If you want to update many records in the subform... your table design
might be suspect. In any case you'll need to run an update query.

John W. Vinson[MVP]
 
John,

I am only updating one record in the subform. I am getting the error message
"Method or Database Object not found". This is the code I put in.

Me.sfm_TblOrders.Form![Credit Adjustment] = True

The " .sfm_TblOrders" is highlighted in the debugger. I've double checked it
and that is the exact name of my subform.

Thanks in advance,
Brian


John said:
I have a field in my main form that is a combo box with "Original" and
"Credit Adjustment" as the options. When "Credit Adjustment" (default value
is CA) is selected, i would like the yes/no field in the subform for "Credit
Adjustment" to be set as yes (True).

The (logical) problem here is that typically a subform might have
zero, one, or any number of records related to the mainform record. So
there isn't "a" yes/no field in the subform - there might be 22,841 of
them!

What is the recordsource of the subform? Do you want to update only
the currently selected subform record? If so use

Me.Subformname.Form![Credit Adjustment] = True

using the Name property of the subform.

If you want to update many records in the subform... your table design
might be suspect. In any case you'll need to run an update query.

John W. Vinson[MVP]
 
John,

I am only updating one record in the subform. I am getting the error message
"Method or Database Object not found". This is the code I put in.

Me.sfm_TblOrders.Form![Credit Adjustment] = True

The " .sfm_TblOrders" is highlighted in the debugger. I've double checked it
and that is the exact name of my subform.

There are two names involved: the name of the Subform Control on the
mainform (visible when you highlight just the box, the outer rim of
the subform, in form design view); and the name of the Form contained
within that control. It is the former which is neede in this
expression; the name of the form itself is irrelevant.

John W. Vinson[MVP]
 
Back
Top