Field Update

  • Thread starter Thread starter Jacques Steinman
  • Start date Start date
J

Jacques Steinman

In one of the previous posts it waas suggested that for field updating based
on a selection I should use the following code:

Private Sub d_itemid_AfterUpdate()

With Me.d_itemid
If Not IsNull(.Value) Then
Me.d_cost = .Column(3)
End If
End With

End Sub

This does the job, but Id like to update more than one field. Can I simply
add another line like this:

Private Sub d_itemid_AfterUpdate()

With Me.d_itemid
If Not IsNull(.Value) Then
Me.d_cost = .Column(3)
Me.d_maxsell = .Column(5)
End If
End With

End Sub

Would this work?
 
Yes, it should work. Why didn't you just try: it would have been far faster
than posting a question and waiting for an answer!

Incidentally, since you're using the Column collection, I assume d_itemid
must be a combo box. The AfterUpdate event will never fire if no record's
been selected, so there's really little point in checking for Null. (The
only reason would be if you're calling that procedure from code elsewhere in
the application). That means all you should need is

With Me.d_itemid
Me.d_cost = .Column(3)
Me.d_maxsell = .Column(5)
End With
 
Because I encountered a small problem and wanted confirmation before I retry.
If I encounter the same hiccup I'll post it.
 
Back
Top