Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL and dbGrid

Posted on 1998-09-12
1
Medium Priority
?
164 Views
Last Modified: 2010-04-30
I use a sql statement in a command button to find records by
name.  However, after the query is run, the dbGrid and my
textbox fields are limited to the record found by the query.
How do I restore the 'default settings in order to see
all the records in the table?
The sql code is provided below.

Thanks.

Private Sub Command1_Click()
Dim prompt, name
Dim SQLSTR As String
Set dbsbiblio = OpenDatabase("\vb\biblio.mdb")
prompt = "Enter Name"
name = InputBox$(prompt)
SQLSTR = ("SELECT [last],[first],[dob],[nf_name],[cmhc] " _
        & "FROM client where first = '" & name & "';")
Set datPrimaryRS.Recordset = _
 dbsbiblio.OpenRecordset(SQLSTR, dbOpenDynaset)
End Sub
0
Comment
Question by:foxsage
[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
1 Comment
 
LVL 4

Accepted Solution

by:
mcix earned 100 total points
ID: 1434498
You could define a constant that has the "default" SQL statement.

In a form it would be defined like this:

Private Const DEFAULT_SQL_STATEMENT As String = "SELECT * FROM SOMETABLE"

Private Sub RESTORE_Click()
Dim prompt, name
Dim SQLSTR As String
Set dbsbiblio = OpenDatabase("\vb\biblio.mdb")
Set datPrimaryRS.Recordset = _
 dbsbiblio.OpenRecordset(DEFAULT_SQL_STATEMENT, dbOpenDynaset)

End Sub

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 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