First (only) record in table problem

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I want to read values from the one and only record in the table. (No
manipulating, just read them and use them elsewhere.) No matter what I've
tried, I can't seem to get it. I know the 'strPeriodTableName' is correct, as
I've just removed my msgbox test. So that's not it. I've tried the 'MoveNext',
both with and without the loop. I've tried not using either the 'MoveFirst' or
'MoveNext'. Here's my code:

' find out the period we dealt/started with...
Dim intPeriodYear As Integer, intPeriodMonth As Integer
Set DAOdbs = CurrentDb
'------------------------------------------------------------
'
' Open the 'Period' table
'
Set DAOrs = DAOdbs.OpenRecordset(strPeriodTableName)

DAOrs.MoveFirst

' Do While Not DAOrs.EOF
' DAOrs.MoveNext
' Loop

intPeriodYear = DAOrs![PeriodYear]
intPeriodMonth = DAOrs![PeriodMonth]

DAOrs.Close
Set DAOrs = Nothing

DAOdbs.Close
Set DAOdbs = Nothing

Here's the error msg I get from Access:

Error #91, Object variable or With block variable not set.

Any thoughts/suggestions would be most welcome. Thanks in advance,

Tom
 
Back
Top