Code not working... Please Help!

  • Thread starter Thread starter Gina Whipp
  • Start date Start date
G

Gina Whipp

Getting message on 'If rst.RecordCount > 3 Then' <Object variable or With
block variable not set>

Dim rst As DAO.Recordset
Dim RecordCount As DAO.Database
Dim PagesToInsert As Integer

If rst.RecordCount > 3 Then
PagesToInsert = Round((rst.RecordCount) + 0.5 / 1)
End If

MsgBox "Please insert" & PagesToInsert & "pages to print your form.",
vbOKOnly, "Printer Attention Required"


Thanks in advance....
Gina Whipp
 
While you've declared rst to be a recordset, you haven't instantiated it.

What is that recordset supposed to represent? You have to tell Access...
 
.... and I am not sure why you declared RecordCount as a Database Object?

Shouldn't it be Long?
 
I did fix the RecordCount but still not working... I guess I don't
understand... Everything I try to Set comes up with this not available in
..mdb, so I'm going to try something else...

Thanks anyway...
 
You still need to address Doug Steele's advice, that you have not indicated
what set of records rst is meant to be. You need to set rst to the query
that you want to get a recordcount from. Something like:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim PagesToInsert As Integer

Set db = CurrentDb()
Set rst = db.OpenRecordset("qryDataToPrint")
rst.MoveLast

If rst.RecordCount > 3 Then
PagesToInsert = Round((rst.RecordCount) + 0.5 / 1)
Else
PagesToInsert = 1
End If
MsgBox "Please insert " & PagesToInsert & " pages to print your form.",
vbOKOnly, "Printer Attention Required"


Doug
 

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

Similar Threads

Sql question 17
Code Help 9
Code wont work 2
Getting data from Access to Excel 4
Do/Loop Dilemma 6
Working with sequential Data 5
Help with Code 1
Help with code 5

Back
Top