Detecting if Cancel button has been pressed on the Find dialog

A

Anthony Ryan

I have a main form for entering data, etc
I also have a Form being used as a report to show data based on VBA
code, etc.

I have added an eventcode to the form's detail section
Private Sub Detail_DblClick(Cancel As Integer)

If Me![Request Number] <> "" Then
DoCmd.OpenForm "tblJobTicket Request", , , "[Request Number]="
& Me!Request Number]
End If
End Sub

Then the form opens up showing the data. The record control at the
bottom of the show that it is filtered (I assumed its based upon
"[Request Number]=" & Me!Request Number])
The form that as being displayed has a find button, but it can't find
any other records because of it being filtered.

I have added the line Me.RecordSource = "SELECT * FROM [tblJobTicket
Request];"
just before the code
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

so I have all available records to find.

Question 1 - Is there a better way of doing it?

Because I have inserted the line
Me.RecordSource = "SELECT * FROM [tblJobTicket Request];"

The data being shown on the form is the very first record. Which now
leads me into the second question

Question 2 - When the user presses the cancel button on the Find
Dialog the data being shown is the very first record of the databse
not the one being shown originally. Can you determine if the cancel
button was pressed so if needed a query could be done to filter the
data back to the originally record being displayed?


Thanks for any help

Anthony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top