怎么按流水号的开头字来分表查询
如何按流水号的开头字来分表查询
当流水号开头为R时查询temp1表,为T时查询temp2表
If Combo1.Text = " " Then
MsgBox "流水号不可为空 ", 6, "提示 "
Else
sql1= "select * from temp1 where ID= ' " & Combo1.Text & " ' "
sql2= "select * from temp2 where ID= ' " & Combo1.Text & " ' "
rs.Open ???, cn, 1, 3
If Not rs.EOF Then
..........
------解决方案--------------------
Dim strTable As String
Select Case Left(Combo1.Text, 1)
Case "R "
strTable = "TEMP1 "
Case "T "
strTable = "TEMP2 "
Case Else
strTable = "TEMP3 "
End Select
SQL = "select * from " & strTable & " where ID= ' " & Combo1.Text & " ' "
rs.Open SQL, cn, 1, 3
当流水号开头为R时查询temp1表,为T时查询temp2表
If Combo1.Text = " " Then
MsgBox "流水号不可为空 ", 6, "提示 "
Else
sql1= "select * from temp1 where ID= ' " & Combo1.Text & " ' "
sql2= "select * from temp2 where ID= ' " & Combo1.Text & " ' "
rs.Open ???, cn, 1, 3
If Not rs.EOF Then
..........
------解决方案--------------------
Dim strTable As String
Select Case Left(Combo1.Text, 1)
Case "R "
strTable = "TEMP1 "
Case "T "
strTable = "TEMP2 "
Case Else
strTable = "TEMP3 "
End Select
SQL = "select * from " & strTable & " where ID= ' " & Combo1.Text & " ' "
rs.Open SQL, cn, 1, 3