Field Update

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?
 
D

Douglas J. Steele

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
 
J

Jacques Steinman

Because I encountered a small problem and wanted confirmation before I retry.
If I encounter the same hiccup I'll post it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top