DataGrid1_KeyDown事件修改如下:
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
订单编号 = DataGrid1.Columns("订单编号").Value
酒店名称 = DataGrid1.Columns("酒店名称").Value
厨房 = DataGrid1.Columns("厨房").Value
Adodc1.Recordset.Close
Adodc1.Recordset.CursorLocation = adUseServer
Adodc1.Refresh
If KeyCode = 13 Then '以下是在datagrid1上选定按下enter的情况
sql1 = "select 订单表.酒店货物名称,订单表.转换酒店单价 as 单价,订单表.送货单数量,订单表.酒店单位,订单表.备注 from 订单表,订单编号表头 where 订单表.id_编号=订单编号表头.id_编号 and 订单编号 ='" & 订单编号 & "' order by id_订单"
Adodc2.RecordSource = sql1
Adodc2.Refresh
Set DataGrid2.DataSource = Adodc2
DataGrid2.Visible = True
Label7.Caption = "订单编号:" & 订单编号
Label3.Caption = "酒店名称:" & 酒店名称
Label4.Caption = " 厨房:" & 厨房
Frame3.Visible = True
Call 初始化datagrid2
sql1 = "select count(酒店名称) as a from 订单表,订单编号表头 where 订单表.id_编号=订单编号表头.id_编号 and 订单编号表头.订单编号='" & 订单编号 & "'and 订单表.转换酒店单价 is null "
Adodc3.RecordSource = sql1
Adodc3.Refresh
If Adodc3.Recordset.Fields("a") <> 0 Then
DataGrid2.AllowUpdate = False
MsgBox "有没有价格的货物,请先确定价格,再来填写送货数量!", vbOKOnly + vbInformation, " 提示信息"
Exit Sub
Else
DataGrid2.AllowUpdate = True
End If
DataGrid2.SetFocus
SendKeys "{right}"
SendKeys "{right}"
End If
End Sub
[
本帖最后由 lowxiong 于 2014-3-8 00:08 编辑 ]