| |

VerySource

 Forgot password?
 Register
Search
View: 718|Reply: 1

How to query by table by the beginning of the serial number

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-15 15:30:02
| Show all posts |Read mode
Query the temp1 table when the serial number starts with R, and the temp2 table when it is T

If Combo1.Text = "" Then
MsgBox "The serial number cannot be empty", 6, "Hint"
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
..........
Reply

Use magic Report

0

Threads

14

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-6-18 18:30:01
| Show all posts
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
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list