Can't figure how code for IIf + SQL

  • Thread starter Thread starter Chen
  • Start date Start date
C

Chen

I have a form for the user to enter the items that will be
on a purchase order. The Supplier Name (actually just an
id number on the form) is already set into the form, and
after the user updates the Parts Number field, I want it
to run an SQL statement checking if there is already a
record in the Item table with that particular supplier
name and parts number. If so, I want it to automatically
place the description from the same table for that item
into the description field in the form. However, I just
cannot figure out the correct syntax to do this using
either VB or macros. Can someone help me out? Thanks!
 
'Code Start
Private Sub ItemNumber_AfterUpdate
Me![Description] = DLookUp
("[Description]", "SuppliersItemsTbl", "[ItemID] = " & Me!
[ItemID] & " And [SupplierID] = " & Me![SupplierID]
'So if the result is null, the comments will stay null and
everything's still ok.
End Sub
'Code Ends

HTH,
Ayelet
 
Back
Top