| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:[求助]VB和ACCESS数据库问题
只看楼主 加入收藏
jasonhz
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
 问题点数:0 回复次数:2 
[求助]VB和ACCESS数据库问题
我用的是VB和ACCESS数据库,想在原来基础上增加“性别”这个字段,在ACCESS上已经添加,在代码中只添加了将性别信息录入数据表的代码,运行系统后,VB中出错,需要调试,但性别信息能在数据表中找到,请问高手需要怎么改
Private Sub comok_Click()
Dim mydb1 As Database
Dim myrs1 As Recordset
Set mydb1 = Workspaces(0).OpenDatabase(App.Path & "\kfgl.mdb")
Set myrs1 = mydb1.OpenRecordset("djys", dbOpenTable)
Data1.Recordset.FindFirst "房间号 like" + Chr(34) + DBCombo1.Text + Chr(34) + "and 标志 like" + Chr(34) + "1" + Chr(34) + ""
If Data1.Recordset.NoMatch Then
'添加住宿信息
Data1.Recordset.AddNew
If bh.Text <> "" Then Data1.Recordset.Fields("凭证号码") = bh.Text
If ZSDJ(0).Text <> "" Then Data1.Recordset.Fields("姓名") = ZSDJ(0).Text
If Combo1.Text <> "" Then Data1.Recordset.Fields("证件名称") = Combo1.Text
If ZSDJ(1).Text <> "" Then Data1.Recordset.Fields("证件号码") = ZSDJ(1).Text
If ZSDJ(2).Text <> "" Then Data1.Recordset.Fields("详细地址") = ZSDJ(2).Text
If ZSDJ(3).Text <> "" Then Data1.Recordset.Fields("出差事由") = ZSDJ(3).Text
If DBCombo1.Text <> "" Then Data1.Recordset.Fields("房间号") = Val(DBCombo1.Text)
If ZSDJ(4).Text <> "" Then Data1.Recordset.Fields("客房类型") = ZSDJ(4).Text
If DTP1.Value <> "" Then Data1.Recordset.Fields("住宿日期") = DTP1.Value
If tim1.Value <> "" Then Data1.Recordset.Fields("住宿时间") = tim1.Value
If ZSDJ(5).Text <> "" Then Data1.Recordset.Fields("客房价格") = Val(ZSDJ(5).Text)
If ZSDJ(6).Text <> "" Then Data1.Recordset.Fields("住宿天数") = ZSDJ(6).Text
If ZSDJ(8).Text <> "" Then Data1.Recordset.Fields("折扣") = ZSDJ(8).Text
If ZSDJ(7).Text <> "" Then Data1.Recordset.Fields("宿费") = ZSDJ(7).Text
If Combo2.Text <> "" Then Data1.Recordset.Fields("结款方式") = Combo2.Text
If ZSDJ(9).Text <> "" Then Data1.Recordset.Fields("应收宿费") = ZSDJ(9).Text
If ZSDJ(10).Text <> "" Then Data1.Recordset.Fields("预收金额") = Val(ZSDJ(10).Text)
If DTP2.Value <> "" Then Data1.Recordset.Fields("提醒日期") = DTP2.Value
If tim2.Value <> "" Then Data1.Recordset.Fields("提醒时间") = tim2.Value
If DTP3.Value <> "" Then Data1.Recordset.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then Data1.Recordset.Fields("退宿时间") = tim3.Value
If ZSDJ(11).Text <> "" Then Data1.Recordset.Fields("备注") = ZSDJ(11).Text
If ZSDJ(12).Text <> "" Then Data1.Recordset.Fields("性别") = ZSDJ(12).Text
Data1.Recordset.Fields("日期") = Date
Data1.Recordset.Fields("时间") = Time
' Data1.Recordset.Fields("BZ") = Left(Date, 4) & Right(Left(Date, 7), 2) & Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
Data1.Recordset.Fields("BZ") = Format(Now, "YYYYMMDDHHMM")
Data1.Recordset.Fields("标志") = "1"
'更新记录
Data1.Recordset.Update
'添加住宿预收信息
myrs1.AddNew
If bh.Text <> "" Then myrs1.Fields("凭证号码") = bh.Text
If ZSDJ(0).Text <> "" Then myrs1.Fields("姓名") = ZSDJ(0).Text
If Combo1.Text <> "" Then myrs1.Fields("证件名称") = Combo1.Text
If ZSDJ(1).Text <> "" Then myrs1.Fields("证件号码") = ZSDJ(1).Text
If ZSDJ(2).Text <> "" Then myrs1.Fields("详细地址") = ZSDJ(2).Text
If ZSDJ(3).Text <> "" Then myrs1.Fields("出差事由") = ZSDJ(3).Text
If DBCombo1.Text <> "" Then myrs1.Fields("房间号") = Val(DBCombo1.Text)
If ZSDJ(5).Text <> "" Then myrs1.Fields("客房价格") = Val(ZSDJ(5).Text)
If DTP1.Value <> "" Then myrs1.Fields("住宿日期") = DTP1.Value
If tim1.Value <> "" Then myrs1.Fields("住宿时间") = tim1.Value
If ZSDJ(6).Text <> "" Then myrs1.Fields("住宿天数") = ZSDJ(6).Text
If Combo2.Text <> "" Then myrs1.Fields("结款方式") = Combo2.Text
If ZSDJ(8).Text <> "" Then myrs1.Fields("折扣") = ZSDJ(8).Text
If ZSDJ(7).Text <> "" Then myrs1.Fields("宿费") = ZSDJ(7).Text
If ZSDJ(9).Text <> "" Then myrs1.Fields("应收宿费") = ZSDJ(9).Text
If ZSDJ(10).Text <> "" Then myrs1.Fields("预收金额") = Val(ZSDJ(10).Text)
If DTP2.Value <> "" Then myrs1.Fields("提醒日期") = DTP2.Value
If tim2.Value <> "" Then myrs1.Fields("提醒时间") = tim2.Value
If DTP3.Value <> "" Then myrs1.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then myrs1.Fields("退宿时间") = tim3.Value
If ZSDJ(11).Text <> "" Then myrs1.Fields("备注") = ZSDJ(11).Text
If ZSDJ(12).Text <> "" Then Data1.Recordset.Fields("性别") = ZSDJ(12).Text
myrs1.Fields("日期") = Date
myrs1.Fields("时间") = Time
myrs1.Fields("BZ") = Format(Now, "YYYYMMDDHHMM")
myrs1.Fields("标志") = "1"
'更新记录
myrs1.Update
'更新房间状态
Data2.Recordset.FindFirst "房间号 like " + Chr(34) + DBCombo1.Text + Chr(34) + ""
Data2.Recordset.Edit
Data2.Recordset.Fields("房态") = "入住"
Data2.Recordset.Update
搜索更多相关主题的帖子: 数据库 ACCESS 
2007-06-07 15:48
jasonhz
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
得分:0 
有没有高手指点下吖
2007-06-07 19:33
王者之风
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-6-12
收藏
得分:0 
要在窗体上添加,改属性应该就可以了吧

2007-06-12 17:39
快速回复:[求助]VB和ACCESS数据库问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014792 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved