T
Ttallie
I need to pull the date form the last record of a Table and populate a text
box in a form. Why does the following code pull the date from the first
record instead of the last?
I also created a query that pulls the correct date and put this in the
Control Source of the text box's property sheet and it returns "#NMAE?". I
prefer to do this in the code. Is there better way to accomplish this task?
Private Sub CmdTest_Click()
Dim DimLastDate As Date
DoCmd.OpenTable "TblFuelServiceCharge", acViewNormal, acEdit
DoCmd.GoToRecord , , acLast
DimLastDate = DLookup("[DateEnd]", "TblFuelServiceCharge")
DoCmd.Close acTable, "TblFuelServiceCharge"
Me!TxtTest.SetFocus
Me!TxtTest.Value = DimLastDate
End Sub
box in a form. Why does the following code pull the date from the first
record instead of the last?
I also created a query that pulls the correct date and put this in the
Control Source of the text box's property sheet and it returns "#NMAE?". I
prefer to do this in the code. Is there better way to accomplish this task?
Private Sub CmdTest_Click()
Dim DimLastDate As Date
DoCmd.OpenTable "TblFuelServiceCharge", acViewNormal, acEdit
DoCmd.GoToRecord , , acLast
DimLastDate = DLookup("[DateEnd]", "TblFuelServiceCharge")
DoCmd.Close acTable, "TblFuelServiceCharge"
Me!TxtTest.SetFocus
Me!TxtTest.Value = DimLastDate
End Sub