Sub Proc executes with wrong value

R

Robert

I am using the following sub procedure on a form to update
fields. When testing the variables in the immediate
window, the values returned are correct. However, when
executing with a command button, the OpeningUnleaded is
updated to "Null", not the intended value. Any help is
greatly appreciated and we thank you in advance.

Me.OpeningUnleaded = DLookup
("BalanceUnleaded", "tblFuel", "forms!frmFuel!frmDailyFuel!
EOD=forms!frmFuel!frmDailyFuel!EOD-1")
Me.BalanceUnleaded = (Me.OpeningUnleaded +
Me.PurchasedUnleaded - Me.SalesUnleaded)
Me.TotalUnleaded = (Me.CostUnleaded * Me.SalesUnleaded)
 
W

Wayne Morgan

DLookup("BalanceUnleaded", "tblFuel",
"forms!frmFuel!frmDailyFuel!EOD=forms!frmFuel!frmDailyFuel!EOD-1")<<

The 3rd item in the DLookup should be a WHERE clause (without the word where) referencing
a field in the table tblFuel.
 
H

HSalim

your Dlookup criteria is not correct
it should be
("BalanceUnleaded", "tblFuel", "SomeColumnName = " &
forms!frmFuel!frmDailyFuel! EOD=forms!frmFuel!frmDailyFuel!EOD-1")
 

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