Inserting the Code

Posted on 2009-04-09
Last Modified: 2013-11-25
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



    End With

    Set rs = Nothing

    Set cn = Nothing

End Sub

Open in new window

Question by:Whing Dela Cruz
LVL 69

Accepted Solution

Éric Moreau earned 500 total points
Comment Utility
before you start looping thhrough your data, reset your controls:

for i = 0 to 4
                     cmdTableIndex(i).BackColor = vbWhite
                     cmdTableIndex(i).Caption = ""
                     cmdTabBill(i).BackColor = vbWhite

Author Closing Comment

by:Whing Dela Cruz
Comment Utility
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now