vb中的排列程序
如下,我在"图号"中输入"WS1000002",点击"查询"表格中就只会出现所有的"WS1000002",,这个程序怎么编写(表格中的内容是从2个不同的表中搜索出来的)Dim cn As Connection
Dim rs As adodb.Recordset
Dim rstemp As Recordset
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command2_Click()
Dim FileName As String
FileName = "W:\设计更改单"
ShellExecute Me.hwnd, vbNullString, FileName, vbNullString, vbNullString, 1
End Sub
Private Sub Command1_Click()
sql = "drawingnumber='" & Trim(Text1.Text) & "'"
Call insearch(sql)
End Sub
Private Sub Form_Load()
sql = ""
Call insearch(sql)
Call loadWSPdrawing
End Sub
Private Sub insearch(ByVal sql As String)
Set cn = New Connection
cn.CursorLocation = adUseClient
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\jxc.mdb;"
Set rs = New adodb.Recordset
rs.LockType = adLockOptimistic
If Len(Trim(sql)) <= 0 Then
rs.Open "select * from instore union select * from WSPdrawing", cn, adOpenDynamic
Else
rs.Open "select * from instore union select * from WSPdrawing where " & Trim(sql), cn, adOpenDynamic
End If
Set DataGrid1.DataSource = rs
End Sub
Private Sub loadWSPdrawing()
Set rstemp = New Recordset
rstemp.Open "select * from WSPdrawing", cn, adOpenForwardOnly, adLockReadOnly
If rstemp.RecordCount > 0 Then
rstemp.MoveFirst
Do While Not rstemp.EOF
Text1.Text = rstemp.Fields("drawingnumber")
Text2.Text = rstemp.Fields("description")
rstemp.MoveNext
If rstemp.EOF Then
End If
Loop
End If
End Sub