access数据库查询问题
现在问题是:如何通过用产品名称,带出产品代码和厂家名称?以上二处代码如何修改,谢谢! ElseIf MSH2.Col = 5 Then
Dim rs As New ADODB.Recordset
Call newCnOpen(cnn)
rs.Open "select 厂家名称,产品代码 from 数据库表 where 产品名称=" & Combo1.Text, cnn, 3, 3
Combo1.Clear
If rs.RecordCount > 0 Then
MSH2.TextMatrix(MSH2.Row, 5) = Combo1.Text
MSH2.TextMatrix(MSH2.Row, 9) = rs("厂家名称")
rs.Close: Set rs = Nothing
Call closeCn
End If
Combo1.Text = ""
Combo1.Visible = False
Private Sub msh2_click()
ElseIf MSH2.Col = 5 Then
Combo1.Clear
Combo1.Text = MSH2.TextMatrix(MSH2.Row, 5)
Combo1.Move MSH2.CellLeft, MSH2.CellTop, MSH2.CellWidth + 500 ', MSH2.CellHeight
' Combo1.Visible = True
Dim rs As New ADODB.Recordset
Call newCnOpen(cnn)
rs.Open "select 产品名称 from 数据库表 where 产品代码='" & MSH2.TextMatrix(MSH2.Row, 2) & "'group by 产品名称", cnn, 1, 1
If rs.RecordCount > 0 Then
Do While Not rs.EOF
Combo1.AddItem rs("产品名称")
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
Call closeCn
End If
Combo1.Visible = True
Combo1.SetFocus
ElseIf MSH2.Col = 20 Then
T1.Text = MSH2.TextMatrix(MSH2.Row, MSH2.Col)
T1.Move MSH2.CellLeft, MSH2.CellTop, MSH2.CellWidth, MSH2.CellHeight
T1.BackColor = RGB(222, 222, 222)
T1.Visible = True
T1.SetFocus
End If
End If
MSH2.Refresh
Call ProcessMessages(MSH2)
End Sub