Private Sub command1_Click()
If Option1.Value = True Then
dim mdate as string
   mdate = InputBox("请输入所需日报表的日期(格式:02-1-1):", "日报表日期输入")
 Dim dbsmymanage As Database
 Dim strcnmymanage As String
 Dim strcmdinformation As String
 Dim cnmymanage As ADODB.Connection
 Dim cmdoutputinformation As ADODB.Command
 Dim rstoutputinformation As ADODB.Recordset
 strcnmymanage = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;" & _
         "Data Source=C:\gsbtj\MyManage.mdb"
         
         strcmdinformation = "SELECT 甲班产量, 乙班产量, 丙班产量, 丁班产量, 日期," & _
         "甲班产量 + 乙班产量 + 丙班产量 + 丁班产量 AS 总产量" & _
         " FROM outputinformation WHERE outputinformation.日期 = # 'mdate'#"
        'Set dbsmymanage = OpenDatabase(App.Path + "/mymanage.mdb")
         Set cnmymanage = New ADODB.Connection
         cnmymanage.Open strcnmymanage
         Set cmdoutputinformation = New ADODB.Command
         Set cmdoutputinformation.ActiveConnection = cnmymanage
         cmdoutputinformation.CommandText = strcmdinformation
         'cmdoutputinformation.CommandType = adCmdStoredProc
         Set rstoutputinformation = New Recordset
         'Set rsoutputinformation = cmdoutputinformation.Execute
         rstoutputinformation.Open "outputinformation", cnmymanage
         rptmonthlyoutputinformation.Show
end sub
以上程序运行时,提示找不到行值!望各位高手指点!急!!急!!!

解决方案 »

  1.   

    你的mdate是vb变量,当然不能直接放在sql语句里了"select * from YourTable where Field1=#" & mdate & "#"才是你想要的
      

  2.   

    我试过了,还是不行,是不是在把sql语句写到程序里时哪儿错了,或者数据库、connection、command的调用错了,能不能帮我看看?
      

  3.   

    试试strcnmymanage ="……"
    strcmdinformation="……"Set cnmymanage = New ADODB.Connection
    cnmymanage.Open strcnmymanageSet rstoutputinformation = New Recordset
    rstoutputinformation.Open strcmdinformation, cnmymanage,3,3再不行的话你中断一下程序运行,把完整的sql语句copy下来到access
    里执行看看到底找没找到记录
      

  4.   

    运行后出现ole db操作产生错误,如果可能,请检查每个ole db 状态指,没有工作被完成。还有出现在此环境中不允许操作!
      

  5.   

    在cmdoutputinformation.Name = cnmymanage处出现错误