Solved

Inserting the Code

Posted on 2009-04-09
2
206 Views
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
        Loop
        .Close
    End With
    Set rs = Nothing
    Set cn = Nothing
End Sub

Open in new window

0
Comment
Question by:Whing Dela Cruz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 24115168
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
next
0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 31568811
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

756 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