Solved

SQL and dbGrid

Posted on 1998-09-12
1
153 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
1 Comment
 
LVL 4

Accepted Solution

by:
mcix earned 50 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now