设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1631|回复: 1
打印 上一主题 下一主题

[表] Access报表问题求救

[复制链接]
跳转到指定楼层
1#
发表于 2009-3-17 15:46:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
最近使用Access2003,想调用数据库中的数据生成一个report,发现一个比较奇怪的问题,向大家请教   

我首先创建了一个form一个report, frm确认键的响应代码很简单是这样的:

Dim rpt As Report, ctlNew As Control
Dim tctl As Control

'''这部分是清空report中上次生成的已有的一些控件,但不清空footer中的pagename
DoCmd.OpenReport "rptA3", acViewDesign
    Set rpt = Reports![rptA3]
errordel:
    For Each tctl In rpt.Controls
        If tctl.Name = "pagename" Then
            GoTo a1
        End If
        DeleteReportControl rpt.Name, tctl.Name
a1:    Next tctl
    If rpt.Controls.count > 1 Then GoTo errordel
    rpt.BorderStyle = 1
    rpt.Section(acDetail).Height = 15

'''下面就是创建要在该report上显示的label
Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 2700, 100, 5000, 600)
    ctlNew.Caption = "你好"
    ctlNew.FontBold = True
    ctlNew.FontName = "黑体"
    ctlNew.FontSize = 24
    ctlNew.TextAlign = 2
    ctlNew.SizeToFit
    Set ctlNew = Nothing   

    Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 500, 800, 800, 300)
    ctlNew.Caption = "周期:"
    ctlNew.FontBold = True
    ctlNew.FontName = "黑体"
    ctlNew.FontSize = 10
    ctlNew.SizeToFit
    Set ctlNew = Nothing   

    Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 1500, 800, 1500, 300)
    ctlNew.Caption = DLookup("codename", "tblcode", "codetype='Cycle' and codeNo='" & Me.ComrentDate.value & "'")
    ctlNew.FontName = "黑体"
    ctlNew.FontSize = 10
    ctlNew.SizeToFit
    Set ctlNew = Nothing   

'''然后保存,并打开report
    DoCmd.Save acReport, rpt.Name
    DoCmd.OpenReport rpt.Name, acViewPreview
    DoCmd.Maximize

在实际操作过程中,我打开form点击确认,报表便生成并最大化,但是我关闭报表再点击确认,如此反复多次后,就会出现报表打不开的问题
此时我在编辑界面双击rptA3,也打不开了,提示The expression on format you entered as the event property setting produced the following error:There isn't enough memory to complete the automation object on the | object.
在开发界面编译时,弹出窗口提示out of memory
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2009-3-18 13:40:43 | 只看该作者
  1. Dim rpt As Report, ctlNew As Control
  2. Dim tctl As Control

  3. '''这部分是清空report中上次生成的已有的一些控件,但不清空footer中的pagename
  4. DoCmd.OpenReport "rptA3", acViewDesign
  5.     Set rpt = Reports![rptA3]
  6. errordel:
  7.     For Each tctl In rpt.Controls
  8.         If tctl.Name <> "pagename" Then
  9.         DeleteReportControl rpt.Name, tctl.Name
  10.         End If
  11.     Next
  12.    
  13.     rpt.BorderStyle = 1
  14.     rpt.Section(acDetail).Height = 15

  15. '''下面就是创建要在该report上显示的label
  16. Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 2700, 100, 5000, 600)
  17.     With ctlNew
  18.         .Caption = "你好"
  19.         .FontBold = True
  20.         .FontName = "黑体"
  21.         .FontSize = 24
  22.         .TextAlign = 2
  23.         .SizeToFit
  24.     End With

  25.     Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 500, 800, 800, 300)
  26.     With ctlNew
  27.         .Caption = "周期:"
  28.         .FontBold = True
  29.         .FontName = "黑体"
  30.         .FontSize = 10
  31.         .SizeToFit
  32.     End With

  33.     Set ctlNew = CreateReportControl(rpt.Name, acLabel, acDetail, , , 1500, 800, 1500, 300)
  34.     With ctlNew
  35.         .Caption = DLookup("codename", "tblcode", "codetype='Cycle' and codeNo='" & Me.ComrentDate.Value & "'")
  36.         .FontName = "黑体"
  37.         .FontSize = 10
  38.         .SizeToFit
  39.     End With
  40. '''然后保存,并打开report
  41.     DoCmd.Save acReport, rpt.Name
  42.     DoCmd.OpenReport rpt.Name, acViewPreview
  43.     DoCmd.Maximize
  44.    
  45.     Set rpt = Nothing
  46.     Set ctlNew = Nothing
  47.     Set tctl = Nothing
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-1 06:46 , Processed in 0.079738 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表