Trying to make preview cmd on form

JSRhone

New member
Local time
Today, 03:17
Joined
Apr 26, 2002
Messages
8
Option Compare Database

Private Function PreviewQuery()
'Open the selected query in the Print Preview window
DoCmd.OpenQuery [QueryList Control], acViewPreview
End Function

Private Function DisplayQuery()
'Open the selected query in Datasheet View
DoCmd.OpenQuery [QueryList Control], acViewNormal
End Function

Private Sub List2_BeforeUpdate(Cancel As Integer)

End Sub

But I get the following error: Microsoft Access can't find the field "I" referred to in my expression.

Can any one help me.

Thanks
Joanne
 
Check the list control is bound to the right column. You do not need to define functions as they have no return value. You should define as sub procedures

Eliminate the need for two procedures- incorporate them as follows...

Private Sub OpenTheQuery(bytOpenMode as Byte)

DoCmd.OpenQuery Me![QueryList Control], bytOpenMode
End Sub

Then behind your button that calls the sub procedure do this for datasheet view

OpenTheQuery acViewNormal

and

OpenTheQuery acViewPreview

These sub procedures seem redundant to me as they replicate the functionality that already exists - ho-hum.

Ian
 

Users who are viewing this thread

Back
Top Bottom