| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 465 人关注过本帖
标题:vb中的排列程序
只看楼主 加入收藏
紫露
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2012-12-28
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
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

2013-04-03 08:56
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:7 
数据结构?

无知
2013-04-03 17:30
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:7 
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

增加查询的条件。自己去看一下 SQL 命令 吧。
多表查询,比较烦。

授人于鱼,不如授人于渔
早已停用QQ了
2013-04-03 19:09
紫露
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2012-12-28
收藏
得分:0 
回复 3楼 风吹过b
看 了,也不知道错在哪 里,还请帮个忙,帮我看看
2013-04-08 14:12
快速回复:vb中的排列程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036680 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved