SECOND REQUEST - Article 814779

B

Bev

I am receiving the following error message. I have also
pasted the code below.
"The expression On Open you entered as the event property
setting produce the following error: User-devined type
not defined.
* The expression may not result in the name of a macro,
the name of a user-defined function, or [Event Procedure].
* There may have been an error evaluating the function,
event, or macro.

CODE:
Dim DB As Database
Dim GrpPages As Recordset
Function GetGrpPages()
'Find the group name.
GrpPages.Seek "=", Me![Country]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![Page Number]
End If
End Function
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer,
FormatCount As Integer)
'Find the group.
GrpPages.Seek "=", Me![Country]

If Not GrpPages.NoMatch Then
'The group is already there.
If GrpPages![Page Number] < Me.Page Then
GrpPages.Edit
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
Else
'This is the first page of the group. Therefore,
add it.
GrpPages.AddNew
GrpPages![Country] = Me![Country]
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
Set DB = DBEngine.workspaces(0).databases(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From [Category Group Pages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("Category Group
Pages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"

End Sub

..
 
D

Duane Hookom

I expect that you don't have a reference set to the DAO object library. Open
any module and select Tools|References and the scroll down to find the
Microsoft DAO Object Library. Check it. Then modify the code a little:
Dim DB As DAO.Database
Dim GrpPages As DAO.Recordset
 

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