Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Inserting the Code

The code below is working for identifying the existing of the data. How would i add some kind of code that if the file is not existing the backcolor will turn into vbwhite?
Private Sub Marker()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sql As String
 
    Call OPEN_CON(cn, "MyTable", "Winpos")
    Set rs = New ADODB.Recordset
    sql = "SELECT * FROM The_Table WHERE Table_No in (101,102,103,104)"
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    rs.Open sql, cn
    With rs
        Do While Not .EOF
            Select Case Trim(.Fields("Table_No").Value)
                Case 100
                     cmdTableIndex(0).BackColor = vbRed
                     cmdTableIndex(0).Caption = "Accomodated" & vbNewLine & "100"
                     cmdTabBill(0).BackColor = vbRed
                     
                Case 101
                     cmdTableIndex(1).BackColor = vbRed
                     cmdTableIndex(1).Caption = "Accomodated" & vbNewLine & "101"
                     cmdTabBill(1).BackColor = vbRed
                Case 102
                     cmdTableIndex(2).BackColor = vbRed
                     cmdTableIndex(2).Caption = "Accomodated" & vbNewLine & "102"
                     cmdTabBill(2).BackColor = vbRed
                Case 103
                     cmdTableIndex(3).BackColor = vbRed
                     cmdTableIndex(3).Caption = "Accomodated" & vbNewLine & "103"
                     cmdTabBill(3).BackColor = vbRed
                Case 104
                     cmdTableIndex(4).BackColor = vbRed
                     cmdTableIndex(4).Caption = "Accomodated" & vbNewLine & "104"
                     cmdTabBill(4).BackColor = vbRed
            End Select
            Call .MoveNext
        Loop
        .Close
    End With
    Set rs = Nothing
    Set cn = Nothing
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Thanks, Its work
I post other question regarding with the length of this code. How can i make this code shorter. Hope you'll monitor on it..
Thanks to you more Power