Solved

Inserting the Code

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

623 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