Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay query results in a bound grid control
Description
Keywordsdatabase, bound controls, grid
CategoriesDatabase
 
By Marlon Durana.

When you enter a query into the ComboBox and click the Query button, the program sets the RecordSource property of a Data control to the query and calls its Refresh method. The program also adds the query to the ComboBox's list of choices so you can select the query later. (It would be better if it checked whether the query was already in the list first).

 
Private Sub Command1_Click()
Dim i As Integer

    On Error GoTo ErrorHandler
    With Data1
        .RecordSource = Trim$(Text1.Text)
        .Refresh
    End With

    Text1.AddItem Text1.Text
    Exit Sub

ErrorHandler:
    MsgBox "Error: " & Err.Number & " -->" & _
        Err.Description & ".", vbCritical, "Query Error"
End Sub
 
For information on database programming in VB .NET, see my book Visual Basic .NET Database Programming.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated