Fill textbox from previous data in table and return to table

BadgerLikeSpeed

Registered User.
Local time
Today, 12:54
Joined
Feb 7, 2013
Messages
35
I think (hope) that this is a simple problem, but I can't get my head around it. I'm still a novice at the whole vba/access game, so please reply in simple terms...
I have a table to calculate fuel usage etc. over a weekly period - the user enters the date at the start of the weekvalues at the start, end and any taken in over the week. What I'd like to do is take the week start date to look up the previous weeks end data and fill in the boxes.
I have a query that provides this data, but I'm not sure how to get it in to the boxes, and then get them to fill in the data to the table. I can get the form to activate teh query on filling in the date field, but I don;t really want the query to become active and hide the form - I'd like it all to happen behind the scenes...
Just trying to simplify life for users, but it's complicating mine!
Any tips would be massively appreciated...
 
Code:
WkEnding = DateAdd("d", -1, [Forms]![TestEngDataNew]![WkSt])
MsgBox (WkEnding)
lookup = DLookup("[WatEngDataWeek]![GOEnd]", "[WatEngDataWeek]", "[WatEngDataWeek]![WkEnd] = WkEnding")
Gives me a run time error 2471, with error 'WkEnding'. The message box was just put in to make sure that the date was being calculated correctly, and it is. There is an entry in the table WatEngDataWeek, in the field WkEnd of the correct date.
Where am I going wrong?
 
Are you in the USA? (I mean do you use US format Date/Time display MM/DD/YYYY)
 
GasOil = DLookup("[GOEnd]", "[WatEngDataWeek]", "[WkEnd] = #" & WkEnding & "#")
Worked for me, all good now!
 

Users who are viewing this thread

Back
Top Bottom