Solved

SQL and dbGrid

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…

895 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

12 Experts available now in Live!

Get 1:1 Help Now