How get values from one table to feed a form bound to another table

SteveL

Registered User.
Local time
Today, 08:22
Joined
Dec 3, 2004
Messages
60
This is going to get complicated I'm sure. But here goes. I have a table named tblPrices. I have another table named tblPartsMasters. Both of these tables have a field named "Part_No" which is the index field in both tables. Then I also have a form named frmPartsMasters which is bound to the table tblPartsMasters.

When the form named frmPartsMasters is opened I want to have an oncurrent event that pulls data over from the table named tblPrices and feeds it into a field on the form named "txtEach_Price". The data I want to pull over from tblPrices is the field named "Each_Price". So I guess this is a DLookup function. However, certain criteria has to be met before the field named "txtEach_Price" can be populated.

This criteria is that:
a) A field named "Q1a" in tblPrices is null and also
b) A field named "chkbxInclSC1" in tblPrices is false.

Does anybody help me write this oncurrent event code?

--Steve
 
steve,

maybe try something like this:
Code:
on current

  me.txteach_price = IIF(DLOOKUP("Q1a", "tblprices", _
    "[part_no] = " & me.part_no) = NULL AND _
      DLOOKUP("chkbxInclSC1", "tblprices", 
        "[part_no] = " & me.part_no) = FALSE, _
          DLOOKUP("each_price", "tblprices", _
            "[part_no] = " & me.part_no), NULL)
As an alternative to this, you could write nested IF, THEN statements to save some memory and processing speed if your database is very large.
 

Users who are viewing this thread

Back
Top Bottom