Sub Proc executes with wrong value

  • Thread starter Thread starter Robert
  • Start date Start date
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)
 
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.
 
your Dlookup criteria is not correct
it should be
("BalanceUnleaded", "tblFuel", "SomeColumnName = " &
forms!frmFuel!frmDailyFuel! EOD=forms!frmFuel!frmDailyFuel!EOD-1")
 
Back
Top