Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering query results in access 1

Status
Not open for further replies.

newguy86

Technical User
May 19, 2008
226
US
First, I have built a db logger that records all data changes to a record. What I want to do is have a button on a form that pulls the history of the current record being displayed.

In other words, I open the form, find the record that I am looking for, and if I want to see the history for that record I press a button and when the query runs it automatically filters for the record number that is currently displayed on the form. Instead of bringing up a message box asking for the record number.

Here is my code for those who can help:
Code:
Private Sub Record_History_Click()
On Error GoTo Err_Record_History_Click

    Dim stDocName As String

    stDocName = "tblDbLog Query"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Record_History_Click:
    Exit Sub

Err_Record_History_Click:
    MsgBox Err.Description
    Resume Exit_Record_History_Click
    
End Sub

Any and all suggestions are greatly appreciated.

FYI - The field name of the record number is 'Incident_Number'.

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement?!
 
I'd use a linked subform.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't think that's exactly what I am looking for. Basically what I want is to press a button and have the query run and the query table appears with the records automatically filtered out except those related to the record number displayed.

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement?!
 
In the criteria cell of Incident_Number in [tblDbLog Query]:
=[Forms]![your main form]![your record number control]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
I have no idea how you do it, because I tried the same thing and it didn't work but now it's working exactly like I wanted it to.

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement?!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top