|
|
I have some reports that were created in Access 2002. We now have several 2003 users and they are complaining that they can't open these reports. An error pops up that eventually seems to incriminate the code below as not being valid in Access 2003. Just wondering if anybody might spot a problem with this code, or have other suggestions on how to fix this.
Option Compare Database
Private Sub Command9_Click() On Error GoTo Err_Command9_Click
Dim stDocName As String
stDocName = "Find blanks and by Dept" DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command9_Click: Exit Sub
Err_Command9_Click: MsgBox Err.Description Resume Exit_Command9_Click End Sub Private Sub Find_by_Extension_Click() On Error GoTo Err_Find_by_Extension_Click
Dim stDocName As String
stDocName = "Find by Extension" DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Find_by_Extension_Click: Exit Sub
Err_Find_by_Extension_Click: MsgBox Err.Description Resume Exit_Find_by_Extension_Click End Sub
|
|
You say reports but thes open up queries. Do those queries exist?
I see nothing wrong with the code, but just to make sure, there are two routines listed, probably assoicated with a two buttons on form(s). Are there any others that don't have this problem?
KGF wrote:
[Quoted Text] > I have some reports that were created in Access 2002. We now have > several 2003 users and they are complaining that they can't open > these reports. An error pops up that eventually seems to > incriminate the code below as not being valid in Access 2003. Just > wondering if anybody might spot a problem with this code, or have > other suggestions on how to fix this. > > Option Compare Database > > Private Sub Command9_Click() > On Error GoTo Err_Command9_Click > > Dim stDocName As String > > stDocName = "Find blanks and by Dept" > DoCmd.OpenQuery stDocName, acNormal, acEdit > > Exit_Command9_Click: > Exit Sub > > Err_Command9_Click: > MsgBox Err.Description > Resume Exit_Command9_Click > > End Sub > Private Sub Find_by_Extension_Click() > On Error GoTo Err_Find_by_Extension_Click > > Dim stDocName As String > > stDocName = "Find by Extension" > DoCmd.OpenQuery stDocName, acNormal, acEdit > > Exit_Find_by_Extension_Click: > Exit Sub > > Err_Find_by_Extension_Click: > MsgBox Err.Description > Resume Exit_Find_by_Extension_Click > > End Sub
|
|
Forget that, after doing some more debugging I found the offensive code. when I REM it out the report works fine. Something here that 2003 doesn't like: Anybody have an idea on how to fix this?
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) Const WHITE = 16777215 'Const YELLOW = 65535
If (Me![LineNum] Mod 2) = 0 Then Me![Name].BackColor = RGB(230, 230, 230) Me![Ext].BackColor = RGB(230, 230, 230) Else Me![Name].BackColor = WHITE Me![Ext].BackColor = WHITE End If End Sub
|
|
Mike thank you, but I found the problem, The second set of code I Posted was gotten from the internet, and it makes alternating colored lines on the report. When I eliminated the constant for WHITE and with RGB code instead, it started working fine. 2003 doesn't like something about the way that code was originally written.
"Mike Painter" wrote:
[Quoted Text] > You say reports but thes open up queries. Do those queries exist? > > I see nothing wrong with the code, but just to make sure, there are two > routines listed, probably assoicated with a two buttons on form(s). > Are there any others that don't have this problem? > > KGF wrote: > > I have some reports that were created in Access 2002. We now have > > several 2003 users and they are complaining that they can't open > > these reports. An error pops up that eventually seems to > > incriminate the code below as not being valid in Access 2003. Just > > wondering if anybody might spot a problem with this code, or have > > other suggestions on how to fix this. > > > > Option Compare Database > > > > Private Sub Command9_Click() > > On Error GoTo Err_Command9_Click > > > > Dim stDocName As String > > > > stDocName = "Find blanks and by Dept" > > DoCmd.OpenQuery stDocName, acNormal, acEdit > > > > Exit_Command9_Click: > > Exit Sub > > > > Err_Command9_Click: > > MsgBox Err.Description > > Resume Exit_Command9_Click > > > > End Sub > > Private Sub Find_by_Extension_Click() > > On Error GoTo Err_Find_by_Extension_Click > > > > Dim stDocName As String > > > > stDocName = "Find by Extension" > > DoCmd.OpenQuery stDocName, acNormal, acEdit > > > > Exit_Find_by_Extension_Click: > > Exit Sub > > > > Err_Find_by_Extension_Click: > > MsgBox Err.Description > > Resume Exit_Find_by_Extension_Click > > > > End Sub > > >
|
|
"KGF" <KGF[ at ]discussions.microsoft.com> wrote in message news:587FE02E-8885-4B50-B358-1E5204E4FC6E[ at ]microsoft.com...
[Quoted Text] > Forget that, after doing some more debugging I found the offensive code. > when I REM it out the report works fine. Something here that 2003 doesn't > like: Anybody have an idea on how to fix this? > > Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) > Const WHITE = 16777215 > 'Const YELLOW = 65535 > > If (Me![LineNum] Mod 2) = 0 Then > Me![Name].BackColor = RGB(230, 230, 230) > Me![Ext].BackColor = RGB(230, 230, 230) > Else > Me![Name].BackColor = WHITE > Me![Ext].BackColor = WHITE > End If > End Sub
It isn't clear to me whether it's the WHITE constant that was giving you trouble or the YELLOW constant (commented out). I note that RGB(230, 230, 230) is not yellow. Does it work if you substitute the predefined VB constant for white and yellow:
'----- start of code ----- Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If (Me![LineNum] Mod 2) = 0 Then Me![Name].BackColor = vbYellow Me![Ext].BackColor = vbYellow Else Me![Name].BackColor = vbWhite Me![Ext].BackColor = vbWhite End If
End Sub '----- end of code -----
If you wanted the RGB(230,...) value instead of yellow, and it was the WHITE constant that was a problem, does this work:
'----- start of code ----- Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If (Me![LineNum] Mod 2) = 0 Then Me![Name].BackColor = RGB(230, 230, 230) Me![Ext].BackColor = RGB(230, 230, 230) Else Me![Name].BackColor = vbWhite Me![Ext].BackColor = vbWhite End If
End Sub '----- end of code -----
?
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
|