Private Sub Command3_Click() ' If Option2.Value = False Then If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '当不要补充出库的信息时 MsgBox ("品名与规格不能为空!") Text1(0).SetFocus Exit Sub End If If Trim(Text1(8).Text) = "" Then MsgBox ("请输入领料人!") Text1(7).SetFocus Exit Sub End If Else If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '入库的关键信息 MsgBox ("品名与规格不能为空!") Text1(0).SetFocus Exit Sub End If If Trim(Text1(11).Text) = "" Or Trim(Text1(12).Text) = "" Then '当要补充出库的信息时 MsgBox ("品名与规格不能为空!") Text1(11).SetFocus Exit Sub End If If Trim(Text1(8).Text) = "" Then MsgBox ("请输入领料人!") Text1(7).SetFocus Exit Sub End If End If If IsNumeric(Text1(4)) = False Then MsgBox ("你输入的数量有误,请输入数值!") Text1(4).Text = "" Text1(4).SetFocus Exit Sub End If '-------------------------- ----------------------------------------- Text1(9).Text = Operater1 '----------给进库表增加信息 instorehouse.RecordSource = "select * from instorehouse" instorehouse.Refresh With instorehouse.Recordset .AddNew .Fields(0) = Text1(0).Text .Fields(1) = Text1(1).Text .Fields(2) = Text1(2).Text .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) .Fields(5) = Text1(5).Text .Fields(6) = Date .Fields(7) = Text1(7).Text .Fields(8) = Text1(8).Text .Fields(9) = Text1(9).Text .Fields(10) = Text1(10).Text .Fields(11) = rk .Update End With Call list1disp
stock.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品 stock.Refresh If stock.Recordset.EOF = True Then With stock.Recordset .AddNew .Fields(0) = Text1(0).Text .Fields(1) = Text1(1).Text .Fields(2) = Text1(2).Text .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) .Fields(5) = Text1(5).Text .Update End With Else With stock.Recordset .Fields(4) = .Fields(4) + Text1(4) .Update End With End If '-------------------- '----------给出库表增加信息 outstorehouse.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品 outstorehouse.Refresh
'-------------------- Call clearzore Text1(6) = Date Text1(9) = Operater1 Text1(0).SetFocus End Sub 没有人管啊,难道还要接着刷么????
最新回答
侧耳听风
2024-06-28 02:26:53
Private Sub Command3_Click() ' Command3点击事件 If Option2.Value = False Then '当单选按钮Option2未选中,那么···· If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '当不要补充出库的信息时 MsgBox ("品名与规格不能为空!") '弹出对话框,上书"品名与规格不能为空!",呵呵 Text1(0).SetFocus '控件数组Text1(0)获得焦点 Exit Sub End If If Trim(Text1(8).Text) = "" Then '如果Text1(8)的内容去空格后为空,那么···· MsgBox ("请输入领料人!") '相同的就不写了······ Text1(7).SetFocus Exit Sub End If Else If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '入库的关键信息,Or是或者 MsgBox ("品名与规格不能为空!") Text1(0).SetFocus Exit Sub End If If Trim(Text1(11).Text) = "" Or Trim(Text1(12).Text) = "" Then '当要补充出库的信息时 MsgBox ("品名与规格不能为空!") Text1(11).SetFocus Exit Sub End If If Trim(Text1(8).Text) = "" Then MsgBox ("请输入领料人!") Text1(7).SetFocus Exit Sub End If End If If IsNumeric(Text1(4)) = False Then '如果Text1(4)输入的不是数字格式(IsNumeric),那么···· MsgBox ("你输入的数量有误,请输入数值!") Text1(4).Text = "" Text1(4).SetFocus Exit Sub End If '-------------------------- ----------------------------------------- Text1(9).Text = Operater1 '将Operater1变量中的内容写入Text1(9)中 '----------给进库表增加信息 instorehouse.RecordSource = "select * from instorehouse" '建立数据库查询,查找数据库instorehouse表的所有内容 instorehouse.Refresh '数据库刷新 With instorehouse.Recordset '在instorehouse.Recordset上执行一系列的语句,知道end with .AddNew '添加新纪录(如上面不加with,这里就要写instorehouse.Recordset.AddNew),懂了吧? .Fields(0) = Text1(0).Text '数据库第0字段,也就是第一列,当前行写入Text1(0)的内容 .Fields(1) = Text1(1).Text '数据库第1字段,也就是第二列,当前行写入Text1(1)的内容 .Fields(2) = Text1(2).Text '下面都一样 .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) 'Val将文本型转换成数字型 .Fields(5) = Text1(5).Text .Fields(6) = Date '内容为Date变量值 .Fields(7) = Text1(7).Text .Fields(8) = Text1(8).Text .Fields(9) = Text1(9).Text .Fields(10) = Text1(10).Text .Fields(11) = rk .Update '更新数据库记录 End With Call list1disp '调用 list1disp 方法
stock.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品,查询数据库,添加了条件,查找stock表中,品名 =Text1(0)而且 规格 = Text1(1)的记录 stock.Refresh '字符串连接最好用&号,不要用+号,如:品名 ='" & Trim(Text1(0)) If stock.Recordset.EOF = True Then '如果可以查到记录 With stock.Recordset '下面都一样 .AddNew .Fields(0) = Text1(0).Text .Fields(1) = Text1(1).Text .Fields(2) = Text1(2).Text .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) .Fields(5) = Text1(5).Text .Update End With Else With stock.Recordset .Fields(4) = .Fields(4) + Text1(4) .Update End With End If '-------------------- '----------给出库表增加信息 outstorehouse.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品 outstorehouse.Refresh
'-------------------- Call clearzore '调用clearzore方法 Text1(6) = Date Text1(9) = Operater1 Text1(0).SetFocus End Sub
第一次写这么详细的注释,呵呵
听风于野
2024-06-28 09:39:41
Private Sub Command3_Click() ' 确定按扭 If Option2.Value = False Then If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '当不要补充出库的信息时 MsgBox ("品名与规格不能为空!") Text1(0).SetFocus Exit Sub End If If Trim(Text1(8).Text) = "" Then MsgBox ("请输入领料人!") Text1(7).SetFocus Exit Sub End If Else If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Then '入库的关键信息 MsgBox ("品名与规格不能为空!") Text1(0).SetFocus Exit Sub End If If Trim(Text1(11).Text) = "" Or Trim(Text1(12).Text) = "" Then '当要补充出库的信息时 MsgBox ("品名与规格不能为空!") Text1(11).SetFocus Exit Sub End If If Trim(Text1(8).Text) = "" Then MsgBox ("请输入领料人!") Text1(7).SetFocus Exit Sub End If End If If IsNumeric(Text1(4)) = False Then MsgBox ("你输入的数量有误,请输入数值!") Text1(4).Text = "" Text1(4).SetFocus Exit Sub End If '-------------------------- ----------------------------------------- Text1(9).Text = Operater1 '----------给进库表增加信息 instorehouse.RecordSource = "select * from instorehouse" instorehouse.Refresh With instorehouse.Recordset .AddNew .Fields(0) = Text1(0).Text .Fields(1) = Text1(1).Text .Fields(2) = Text1(2).Text .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) .Fields(5) = Text1(5).Text .Fields(6) = Date .Fields(7) = Text1(7).Text .Fields(8) = Text1(8).Text .Fields(9) = Text1(9).Text .Fields(10) = Text1(10).Text .Fields(11) = rk .Update End With Call list1disp
stock.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品 stock.Refresh If stock.Recordset.EOF = True Then With stock.Recordset .AddNew .Fields(0) = Text1(0).Text .Fields(1) = Text1(1).Text .Fields(2) = Text1(2).Text .Fields(3) = Text1(3).Text .Fields(4) = Val(Text1(4).Text) .Fields(5) = Text1(5).Text .Update End With Else With stock.Recordset .Fields(4) = .Fields(4) + Text1(4) .Update End With End If '-------------------- '----------给出库表增加信息 outstorehouse.RecordSource = "select * from stock where 品名 ='" + Trim(Text1(0)) _ + "' and 规格 = '" + Trim(Text1(1).Text) + "'" '查找库中是否有该物品 outstorehouse.Refresh
'-------------------- Call clearzore Text1(6) = Date Text1(9) = Operater1 Text1(0).SetFocus End Sub