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
Solved

Inserting the Code

Posted on 2009-04-09
2
205 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
Reading the Contents of a Directory In Access VBA 5 77
using web browser with BING 40 131
transition to visual .net from vb6 5 37
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 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