设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[窗体] 请帮忙看看这段代码哪里出错了

[复制链接]
跳转到指定楼层
1#
发表于 2010-3-18 13:44:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好
我是access新手
现想请大家帮我看看下面这段代码哪里出错了
谢谢
  1. Private Sub 保存信息_Click()
  2. On Error GoTo Err_保存信息_Click:
  3. Dim Stemp As String
  4. If Me![职员ID] <> "" Then
  5. Stemp = "insert into 职员内部调动"
  6. Stemp = Stemp & "(职员ID,姓名,性别,原部门,新部门,调动日期,调动原因,备注)"
  7. Stemp = Stemp & "values('" & Me![职员ID] & "','" & Me![姓名] & "',"
  8. Stemp = Stemp & "'" & Me![性别] & "'," & Me![原部门] & "',"
  9. Stemp = Stemp & "'" & Me![新部门] & "'," & Me![调动日期] & "',"
  10. Stemp = Stemp & "'" & Me![调动原因] & "'," & Me![备注] & "')"
  11. DoCmd.RunSQL Stemp
  12. Stemp = "update 职员基本资料"
  13. Stemp = Stemp & "set 部门ID='" & Me![新部门ID] & "'"
  14. Stemp = Stemp & "where 职员ID='" & Me![职员ID] & "'"
  15. DoCmd.RunSQL Stemp
  16. Else
  17. MsgBox "'职员ID'不能为空,请重新输入!", vbOKOnly, "警告"
  18. Me![职员ID].SetFocus
  19. End If
  20. Me![职员内部调动管理子窗体].Requery
  21. exit_保存信息_click:
  22. Exit Sub
  23. Err_保存信息_Click:
  24. MsgBox Err.Description
  25. Resume exit_保存信息_click
  26. End Sub
复制代码

本帖子中包含更多资源

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

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2010-3-18 13:50:54 | 只看该作者
Stemp = Stemp & "'" & Me![新部门] & "'," & Me![调动日期] & "',"
这一句,改成
Stemp = Stemp & "'" & Me![新部门] & "',#" & Me![调动日期] & "#,"
3#
发表于 2010-3-18 14:03:34 | 只看该作者
Stemp = Stemp & "(职员ID,姓名,性别,原部门,新部门,调动日期,调动原因,备注)"

Stemp = Stemp & "values('" & Me![职员ID] & "','" & Me![姓名] & "',"

把第二句改为Stemp = Stemp & "  values('" & Me![职员ID] & "','" & Me![姓名] & "',"多加一个空格

Stemp = "update 职员基本资料"

Stemp = Stemp & "set 部门ID='" & Me![新部门ID] & "'"

Stemp = Stemp & "where 职员ID='" & Me![职员ID] & "'"

这三句都加空格隔开
Stemp = Stemp & "'" & Me![新部门] & "'," & Me![调动日期] & "',"
这一句,改成
Stemp = Stemp & "'" & Me![新部门] & "',#" & Me![调动日期] & "#,"
4#
 楼主| 发表于 2010-3-18 14:05:20 | 只看该作者
Stemp = Stemp & "'" & Me![新部门] & "'," & Me![调动日期] & "',"
这一句,改成
Stemp = Stemp & "'" & Me![新部门] & "',#" & Me![调动日期] & "#,"
咱家是猫 发表于 2010-3-18 13:50


我按您的方法修改了,可是还是显示错误哦

本帖子中包含更多资源

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

x
5#
发表于 2010-3-18 14:13:30 | 只看该作者
薪资不变  前差个引号后又多一个引号。
6#
发表于 2010-3-18 14:24:45 | 只看该作者
Stemp = Stemp & "'" & Me![调动原因] & "'," & Me![备注] & "')"
改成
Stemp = Stemp & "'" & Me![调动原因] & "','" & Me![备注] & "')"
7#
发表于 2010-3-18 14:25:11 | 只看该作者
这些都是自己不够认真的原因.
8#
 楼主| 发表于 2010-3-18 14:38:02 | 只看该作者
薪资不变  前差个引号后又多一个引号。
kangking 发表于 2010-3-18 14:13


加上引号,问题解决
谢谢

  1. Stemp = Stemp & "values('" & Me![职员ID] & "','" & Me![姓名] & "',"
  2. Stemp = Stemp & "'" & Me![性别] & "','" & Me![原部门] & "',"
  3. Stemp = Stemp & "'" & Me![新部门] & "','" & Me![调动日期] & "',"
  4. Stemp = Stemp & "'" & Me![调动原因] & "','" & Me![备注] & "')"
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-13 14:11 , Processed in 0.084131 second(s), 33 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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