473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Display all records in form

266 256MB
hi, i was wondering if someone can help me, i have a form, with an unbound text box and a command button (code below) that searches through the underlying table and filters the results to show only what i searched for. What i would like, is another command button that after i do a search, it shows all of the records in the table again. hopefully that makes sense... any ideas? thanks!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command47_Click()
  2.     Dim strStudentRef As String
  3.     Dim strSearch As String
  4.     Dim strSql As String
  5.  
  6. 'Check txtSearch for Null value or Nill Entry first.
  7.  
  8.     If IsNull(Me![acctsearch]) Or (Me![acctsearch]) = "" Then
  9.         MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
  10.         Me![acctsearch].SetFocus
  11.     Exit Sub
  12. End If
  13. '---------------------------------------------------------------
  14.  
  15. 'Performs the search using value entered into txtSearch
  16. 'and evaluates this against values in Address
  17.  
  18.     DoCmd.ShowAllRecords
  19.                                               'Chr(42)is ascii code for the wildcard symbol
  20.     strSql = "Select * from [Meters] Where Acct Like '" & Chr(42) & Me!acctsearch & Chr(42) & "';"
  21.     Me.RecordSource = strSql
  22.  
  23.     'If one or more matching records are found, they can be displayed one at a time via the navigation buttons
  24.     If Me.Recordset.RecordCount > 0 Then
  25.         acctsearch.SetFocus
  26.         strSearch = acctsearch.Text
  27.  
  28.         acctsearch.SetFocus
  29.         strSearch = acctsearch.Text
  30.         MsgBox "Match Found For: " & strSearch
  31.         acctsearch = Null
  32.  
  33.     'If value not found sets focus back to txtSearch and shows msgbox
  34.     Else
  35.         acctsearch.SetFocus
  36.         strSearch = acctsearch
  37.         MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
  38.             , "Invalid Search Criterion!"
  39.             acctsearch.SetFocus
  40.     End If
  41. End Sub
Mar 9 '09 #1
2 8331
OldBirdman
675 512MB
Expand|Select|Wrap|Line Numbers
  1. strSql = "Select * from [Meters];" 
  2.     Me.RecordSource = strSql 
or, to use only one command button, test for acctsearch = "". Also, when invalid search then lines 37-39 could be
Expand|Select|Wrap|Line Numbers
  1.     MsgBox "Match Not Found For: " & strSearch & " - All Records Displayed", _ 
  2.             , "Invalid Search Criterion!" 
  3.     strSql = "Select * from [Meters];" 
  4.     Me.RecordSource = strSql 
[/code]
Mar 9 '09 #2
didacticone
266 256MB
awesome! works great! thanks a lot!
Mar 9 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: DataBard007 | last post by:
My Access 97 database has a form that contains text boxes that display people's names, addresses, phone numbers, etc. The record source is a single table. I created a NextRecord and Previous...
3
by: Daniel Tan | last post by:
Hi, i got a subform and inside got some records. But i want to press a button and make all those records to a report. It only display all those records with same Job Order no. I want to display all...
0
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record...
3
by: Cillies | last post by:
Hi, I want to display the number of records in a form on an access 2002 database. I know that under properties you can select navigation button, which allows the user to flick through the...
9
by: Sandy | last post by:
Hi all, I have a form to list records (frmListIssue) which I call from different other forms. My wish is to display a message when the form is called and empty; no records to display. I want to...
3
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
2
by: kev | last post by:
Hi Folks, I have created a search query in which it successfully returns correct results. When there are no records returned, instead of giving out a blank form i created a pop-up msg which is...
3
by: ApexData | last post by:
I am using a continuous form for display purposes. Above this form, a single record is displayed so that when the user presses my NewButton they can enter a NewRecord which gets added to the...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.