get value from looping table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi! Please help me! i have a filed ADay on the table. when i loop through
rows using "aDate = rst![ADay]" everything goes fine until there is a null.
and when it has null my program stop. and when i use "aDate =
DLookup("[ADay]", "Table1")", it would work good even if i have null and it
would go through. but when it is looping it would have the first value that
it get all the way. and it is not suppose to. the values on records changes.
but i don't get it why it is keeping the old value all the time. is there any
other function i should use it. help me please!

aDate = DLookup("[ADay]", "Table - List Empl and Contr")
aDate = rst![ADay]
MsgBox (aDate)
 
First, please post ALL of your code as it helps to see the big picture.
Second, please post the exact error message thats being generated.

Apart from that I'd bet money that your code is mising some things...

First, I'm willing to bet that you don't have aDate declared as a
variant. If you have it declared as a DATE, or any other type, and try
to put a NULL value into it, you'll get an error.

Second, I'm also willing to be that you don't have the statement in a
loop. A loop structure is the *ONLY* way to truely cycle through each
record in a recordset. To that end I would also bet that you're not
familar with the .MoveNext method - without it the pointer will remain
on the first record return.

Dim aDate as Variant

While Not rs.EOF
aDate = rs![ADay]
debug.print aDate
rs.moveNext
Wend

'And of course always cleanup after yourself
rs.Close
Set rs = Nothing

That should get you head in the right direction
 
Back
Top