请教高手一个问题
我做了一个小程序
下面的代码是程序的显示列表
我想实现一个功能
就是
鼠标放在记录上的时候
图 上红色的地方获取本条记录的ID
目的就是为了获取此条记录的id 打开新窗口显示这条信息
如果有别的方法也可以
本人刚学VB高手指点的时候说的清楚些
谢谢!
代码:
Dim rs_kc As New ADODB.Recordset
Private Sub Combo1_Change()
End Sub
Private Sub Command1_Click()
Dim TextNam, P_lei, So As String
TextNam = Text1.Text
If Trim(Text1.Text) = "输入查询信息" Then
MsgBox ("请输入查询信息")
Text1.SetFocus
Exit Sub
End If
If Trim(Text1.Text) = "" Then
MsgBox ("请输入查询信息")
Text1.SetFocus
Exit Sub
End If
P_lei = fenlei.Text
Select Case P_lei
Case "编号"
If IsNumeric(P_lei) = False Then
MsgBox ("编号只能是数字")
fenlei.SetFocus
Exit Sub
End If
Case "查询项目"
If P_lei = "查询项目" Then
MsgBox ("请选择查询项目")
fenlei.SetFocus
Exit Sub
End If
End Select
库存查询.Show 1
End Sub
Private Sub Command2_Click()
库存列表.Hide
End Sub
Private Sub cmddel_Click()
Dim answer As String
On Error GoTo delerror
answer = MsgBox("确定要删除吗?", vbYesNo, "")
If answer = vbYes Then
DataGrid1.AllowDelete = True
rs_kc.Delete
rs_kc.Update
DataGrid1.Refresh
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
delerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Form_Load()
库存列表.Top = (Screen.Height - 库存列表.Height) / 2
库存列表.Left = (Screen.Width - 库存列表.Width) / 2
Dim Sql As String
Sql = "Select * From product"
rs_kc.CursorLocation = adUseClient
rs_kc.Open Sql, Conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False '不可增加
DataGrid1.AllowDelete = False '不可删除
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_kc
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set DataGrid1.DataSource = Nothing
rs_kc.Close
End Sub
Private Sub Text2_Change()
End Sub
图片:
[此贴子已经被作者于2006-1-6 11:58:54编辑过]