设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12下一页
返回列表 发新帖
查看: 1135|回复: 10
打印 上一主题 下一主题

[窗体] 请帮助看看这些语句中那个地方有错误?

[复制链接]
跳转到指定楼层
1#
发表于 2009-8-24 16:25:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请帮助看看这些语句中那个地方有错误?每次运行系统提示编译错误
Private Sub Release_Status_AfterUpdate() If Me.Release_Status = True Then Me.Release_Date = Date Else Me.Release_Date = "" End If If MsgBox("pls, sure release this order ?", vbInformation + vbYesNo) = vbNo Then Me.Release_Status = False Exit Sub End If Dim DB As DAO.Database Set DB = CurrentDb Dim SQLText As String Dim step As Integer step = 1 SQLText = "INSERT INTO [PaiChan_REMOTE] (Team, Release_Date,Remark,CO_NO,Line_No,CO_Item,QTY,Serial_No,Desc,PROM_DATE,Release_Status)" SQLText = SQLText + "SELECT Forms![paichan]![Team] AS [Team], Release_Date AS [Release_Date], Remark AS [Remark], CO_NO AS [CO_NO],Line_No as [Line_No],CO_Item as [CO_Item],qty as [qty],Serial_No as [Serial_No],Desc as [Desc],PROM_DATE as [PROM_DATE],Release_Status as [Release_Status];" CurrentDb.Execute.SQLText Me.Release_Status.Locked = True End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2009-8-24 16:43:18 | 只看该作者
晕,你不传例子,至少也要排好版。
3#
发表于 2009-8-24 16:59:06 | 只看该作者
这样能够通过编译:
Private Sub Release_Status_AfterUpdate()
  If Me.Release_Status = True Then
    Me.Release_Date = Date
  Else
    Me.Release_Date = ""
  End If
  If MsgBox("pls, sure release this order ?", vbInformation + vbYesNo) = vbNo Then
    Me.Release_Status = False
    Exit Sub
  End If
  Dim DB As DAO.Database
  Set DB = CurrentDb
  Dim SQLText As String
  Dim step As Integer
  step = 1
  SQLText = "INSERT INTO [PaiChan_REMOTE] (Team, Release_Date,Remark,CO_NO,Line_No,CO_Item,QTY,Serial_No,Desc,PROM_DATE,Release_Status)"
  SQLText = SQLText + "SELECT Forms![paichan]![Team] AS [Team], Release_Date AS [Release_Date], Remark AS [Remark], CO_NO AS [CO_NO],Line_No as [Line_No],CO_Item as [CO_Item],qty as [qty],Serial_No as [Serial_No],Desc as [Desc],PROM_DATE as [PROM_DATE],Release_Status as [Release_Status];"
  CurrentDb.Execute SQLText
  Me.Release_Status.Locked = True
End Sub
4#
 楼主| 发表于 2009-8-25 07:44:27 | 只看该作者
系统提示有错误请帮助看看

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
5#
 楼主| 发表于 2009-8-25 09:59:58 | 只看该作者
我已将附件上传,请老师们帮助修改,谢谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
6#
发表于 2009-8-25 13:29:33 | 只看该作者
本帖最后由 aslxt 于 2009-8-25 14:31 编辑

5# yanwei82123300
1、你的代码是这样:
Private Sub Release_Status_AfterUpdate()
Private Sub Release_Status_AfterUpdate()
...
应该删掉一个,变为:
Private Sub Release_Status_AfterUpdate()
...
2、你的表Serial_No字段为主键,不能直接引用窗体的数据,防止可能的重复
3、SQLText的值应该是下列描述(如果直接引用Serial_No的话)
  SQLText = "INSERT INTO [PaiChan_REMOTE] (Team, Release_Date,Remark,CO_NO,Line_No,CO_Item,QTY,Serial_No,[Desc],PROM_DATE,Release_Status) "
  SQLText = SQLText + "values (" & """" & Team & """" & ", #" & Nz(Release_Date, Date) & "#,  " & """" & Nz(Remark, "") & """" & "," & """" & CO_NO & """" & "," & """" & Line_No & """" & "," & """" & CO_Item & """" & "," & QTY & "," & """" & Serial_No & """" & "," & """" & Desc & """" & ",#" & PROM_DATE & "#," & Release_Status & ")"
7#
 楼主| 发表于 2009-8-25 14:28:34 | 只看该作者
去掉后提示编译错误,能否帮助修改一下附件例子,谢谢
8#
发表于 2009-8-25 16:07:09 | 只看该作者
7# yanwei82123300
见附件,我把Serial_No设为非主键后,一切正常

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
9#
 楼主| 发表于 2009-8-26 07:20:56 | 只看该作者
aslxt老师非常感谢您的帮助,还有一个小问题每次点击时会出现如图的提示,是什么原因?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
10#
发表于 2009-8-26 08:27:35 | 只看该作者
这是检查sql语句的提示,你可以把msgbox sqltext 删掉即可
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-12 03:00 , Processed in 0.081122 second(s), 34 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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