Corrupted form by modifying query? (1 Viewer)

NJudson

Who farted?
Local time
Today, 15:00
Joined
Feb 14, 2002
Messages
297
I'm using Access 2k and win xp. I created a form based on a query(qryMTX105). The unfiltered query had 1500 records. I have a textbox on the form to enter a number that I want to filter the query on. I never really created forms based on queries or tables before so I think I really goofed something up. In the event procedure of a command button I entered the following code to filter the query based on the criteria the user entered into the textbox.

Private Sub cmdGetTotals_Click()
Dim dbs As DAO.Database
Dim strSQL As String
Dim qdf As Object
Dim cell As String
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("qryMTX105")

cell = Me.txtCell

strSQL = "SELECT TOP 10 MTX105.ID, MTX105.Field1, MTX105.Field2, MTX105.Field3, MTX105.Field4, MTX105.Field5, MTX105.Field6, MTX105.Field7, MTX105.Field8, MTX105.Field9, MTX105.Field10, MTX105.Field11, MTX105.Field12, MTX105.Field13, MTX105.Field14, MTX105.Field15, MTX105.Field16, MTX105.Field17, MTX105.Field18, MTX105.Field19, MTX105.Field20, MTX105.Field21, MTX105.Field22 " & _
"FROM MTX105 " & _
"GROUP BY MTX105.ID, MTX105.Field1, MTX105.Field2, MTX105.Field3, MTX105.Field4, MTX105.Field5, MTX105.Field6, MTX105.Field7, MTX105.Field8, MTX105.Field9, MTX105.Field10, MTX105.Field11, MTX105.Field12, MTX105.Field13, MTX105.Field14, MTX105.Field15, MTX105.Field16, MTX105.Field17, MTX105.Field18, MTX105.Field19, MTX105.Field20, MTX105.Field21, MTX105.Field22 " & _
"HAVING (((MTX105.Field4)='" & cell & "'));"
qdf.SQL = strSQL

Me.Requery
Me.Refresh

qdf.Close
dbs.Close

When I ran this it filtered the query down to 10 records and everything was fine and dandy. The problem is that the form now is stuck at those same 10 records. What I mean by this is that I can close the form out and if I open up the query and remove the filter then the query results in the 1500 records, but when I reopen the form it still only shows those previous 10 records from when the query was filtered. Nothing I can think of doing will get the form to see the whole unfiltered query of 1500 records. I could not find anything similar to this on the forum or on google so I hope that someone may have a clue as to how I could restore the form. Thanks.
 

Users who are viewing this thread

Top Bottom