Hope all is well.
I need to do a similar Lookup for loads of Fields, and I was trying to extrapolate from this.
Basically, a different Contractors can be billed different amounts at different periods.
Eg.
[tblContractor]
Contractor1 may pay 1,000 @ the end of Month 1; 2,000 @ the end of Month 2; 3,000 @ the end of month 3, etc.
Contractor 2 may pay 500 @ the end of Month 1, 750 @ month 2, and so on.
Therefore, after someone enter the Contract Start Date, I'd like [Field 1] to equal 1,000 if ContractorID is 1, 500 if ContractroID is 2, etc.
I tried it like this for the First one using your DLOOKUP, but I'm not sure what commas, parenthesis, or quotation marks to remove from your above code.
I ended up with this:
Code: Select all
Dim varRate As Variant
varRate = DLookup("[Amount1]", "tblContractor", _
"ContractorID = " Me.ContractorID)
Me.Amount1.DefaultValue = Nz(varRate)
And seeing as I'm looking up multiple values, will I have to do this for each 1
Eg
Dim varRate1 as Variant
Dim varRate2 as Variant
Dim varRate 3 as Varient
etc
And finish with . . .
Me.Amount1.DefaultValue = Nz(varRate1)
Me.Amount2.DefaultValue = Nz(varRate2)
Me.Amount3.DefaultValue = Nz(varRate3)
Thanks, as always, for your guidance and help. :)