Solved

SQL and dbGrid

Posted on 1998-09-12
1
161 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 50 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

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses
Course of the Month6 days, 13 hours left to enroll

622 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