First (only) record in table problem

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top