fhow do i determin when the ifnd/replace box is closed?

G

Guest

I have a main form and sub form and need to find records in both
I have the following code:
open form
' Form_Open
'
'------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err
Me.RecordSource = "service request"
DoCmd.Maximize
DoCmd.ApplyFilter ("Query2")
Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Error$
Resume Form_Open_Exit



click button:

Private Sub Command105_Click()
On Error GoTo Last_Err_command105_Click
Me.RecordSource = "Query1"
DoCmd.Requery
Me.Command105.SetFocus
SendKeys "%HA", False
RunCommand acCmdFind
GoTo Exit_Command105_Click
Exit_Command105_Click:
Exit Sub
Last_Err_command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub

The Query1 allows a search of all data in the main form and sub form.
I need to set rhe record source back to Me.RecordSource = "service request"
to remove duplicate recorde in the query when the find/replace is closed
I know rhis an't pretty. but it works. But i need to know how to "reset
the" the record source when the find/replace box is close.

Any help would maybe keep me employed
thanks
andyc
 
M

Michel Walsh

Not really sure of the scenario, but in general, you can make a cover
procedure, like:

Private Sub MyOwnCover()
Command105_Click()
End Sub

Change the event handling procedure for Comand105 button click event for
your cover procedure,... up to now, nothing new, but here is the possibility
to know that Command105 has exited, from any possible of its path, including
error, so:

Private Sub MyOwnCover()

On Error Resume Next ' to 'handle' the error here
Command105_Click()

Me.RecordSource =" whatever "

Debug.Assert Err.Number =0 'since we 'assume' there was no
error... assert it

End Sub



It is far from being fancy, but it should work. If command105_click has only
one possible exit point, you can avoid the cover procedure, adding the
single extra line of code about the RecordSource there.



Hoping it may help,
Vanderghast, Access MVP
 
G

Guest

--
andyc


Michel Walsh said:
Not really sure of the scenario, but in general, you can make a cover
procedure, like:

Private Sub MyOwnCover()
Command105_Click()
End Sub

Change the event handling procedure for Comand105 button click event for
your cover procedure,... up to now, nothing new, but here is the possibility
to know that Command105 has exited, from any possible of its path, including
error, so:

Private Sub MyOwnCover()

On Error Resume Next ' to 'handle' the error here
Command105_Click()

Me.RecordSource =" whatever "

Debug.Assert Err.Number =0 'since we 'assume' there was no
error... assert it

End Sub



It is far from being fancy, but it should work. If command105_click has only
one possible exit point, you can avoid the cover procedure, adding the
single extra line of code about the RecordSource there.



Hoping it may help,
Vanderghast, Access MVP






Thank you for your answer. However, I did not ask the question right. Let me try again.

I have a form Work order (with the record source of the table Service
request). The form Work order has a sub form (actions with a record source
of table actions, linked child field of “work order numberâ€). There are
other filters and controls on the forms and this works great for entry of
service calls and actions taken.

All well to this point. Now I have a request to find work orders with edit
– find. Ok I added the button Command_105 and and used the event procedure
Onclick to bring up the “customized†find/replace dialog box.. Works fine
BUT will only find in the main form Work order not the sub form actions. Darn
nothings easy.

So I made the query (query1)

SELECT [service request].*, [It actions].*, *
FROM [service request] LEFT JOIN [It actions] ON [service request].[Service
Request Number]=[It actions].[Work Order]
WHERE ((([service request].[Type of Service])="IT hardware" Or ([service
request].[Type of Service])="Point of Care" Or ([service request].[Type of
Service])="CPSI"))
ORDER BY [service request].[Service Request Number];

and set the main form (Work order) record source to query1 and added the
text boxs “actions†and “KEY†to the main form. “actions†is hid under the
sub form, KEY is visible when “action†is not null.

Now find will work for the main form and highlight KEYif the word is found
in action.

But query1 as a record source is not good for data entry. If there are
multiple “actions†there are multiple duplications of the main record and
clicking next record appears to the user not to work.

I don’t understand the cover procedure. The Private Sub Command105_Click()
will set the record source to Query1 and open the find/replace box and exit
the sub. It will not wait for the find/replace dialog box to close.
I simply need to know when this dialog box closes and if possible opens so I
can set the main form back to record source = Service request

Hope this is clearer….maybe not?
 
M

Michel Walsh

You are right, the Find/Replace dialog is modeless, it does not wait an
answer, it does not suspend the code execution until it is closed (or turn
invisible), like a modal dialog (such as a MessageBox).

Rather than fighting with the Find/Replace dialog, why not using a Button
(combo box) as navigation tool (with the help of the Wizard) to find (find
next) a record giving a value?


Vanderghast, Access MVP


andyc said:
--
andyc


Michel Walsh said:
Not really sure of the scenario, but in general, you can make a cover
procedure, like:

Private Sub MyOwnCover()
Command105_Click()
End Sub

Change the event handling procedure for Comand105 button click event for
your cover procedure,... up to now, nothing new, but here is the
possibility
to know that Command105 has exited, from any possible of its path,
including
error, so:

Private Sub MyOwnCover()

On Error Resume Next ' to 'handle' the error here
Command105_Click()

Me.RecordSource =" whatever "

Debug.Assert Err.Number =0 'since we 'assume' there was no
error... assert it

End Sub



It is far from being fancy, but it should work. If command105_click has
only
one possible exit point, you can avoid the cover procedure, adding the
single extra line of code about the RecordSource there.



Hoping it may help,
Vanderghast, Access MVP






Thank you for your answer. However, I did not ask the question right.
Let me try again.

I have a form Work order (with the record source of the table Service
request). The form Work order has a sub form (actions with a record
source
of table actions, linked child field of "work order number"). There are
other filters and controls on the forms and this works great for entry of
service calls and actions taken.

All well to this point. Now I have a request to find work orders with
edit
- find. Ok I added the button Command_105 and and used the event
procedure
Onclick to bring up the "customized" find/replace dialog box.. Works fine
BUT will only find in the main form Work order not the sub form actions.
Darn
nothings easy.

So I made the query (query1)

SELECT [service request].*, [It actions].*, *
FROM [service request] LEFT JOIN [It actions] ON [service
request].[Service
Request Number]=[It actions].[Work Order]
WHERE ((([service request].[Type of Service])="IT hardware" Or ([service
request].[Type of Service])="Point of Care" Or ([service request].[Type of
Service])="CPSI"))
ORDER BY [service request].[Service Request Number];

and set the main form (Work order) record source to query1 and added the
text boxs "actions" and "KEY" to the main form. "actions" is hid under
the
sub form, KEY is visible when "action" is not null.

Now find will work for the main form and highlight KEYif the word is found
in action.

But query1 as a record source is not good for data entry. If there are
multiple "actions" there are multiple duplications of the main record and
clicking next record appears to the user not to work.

I don't understand the cover procedure. The Private Sub
Command105_Click()
will set the record source to Query1 and open the find/replace box and
exit
the sub. It will not wait for the find/replace dialog box to close.
I simply need to know when this dialog box closes and if possible opens so
I
can set the main form back to record source = Service request

Hope this is clearer..maybe not?
 
G

Guest

--
andyc


Michel Walsh said:
You are right, the Find/Replace dialog is modeless, it does not wait an
answer, it does not suspend the code execution until it is closed (or turn
invisible), like a modal dialog (such as a MessageBox).

Rather than fighting with the Find/Replace dialog, why not using a Button
(combo box) as navigation tool (with the help of the Wizard) to find (find
next) a record giving a value?


Vanderghast, Access MVP


andyc said:
--
andyc


Michel Walsh said:
Not really sure of the scenario, but in general, you can make a cover
procedure, like:

Private Sub MyOwnCover()
Command105_Click()
End Sub

Change the event handling procedure for Comand105 button click event for
your cover procedure,... up to now, nothing new, but here is the
possibility
to know that Command105 has exited, from any possible of its path,
including
error, so:

Private Sub MyOwnCover()

On Error Resume Next ' to 'handle' the error here
Command105_Click()

Me.RecordSource =" whatever "

Debug.Assert Err.Number =0 'since we 'assume' there was no
error... assert it

End Sub



It is far from being fancy, but it should work. If command105_click has
only
one possible exit point, you can avoid the cover procedure, adding the
single extra line of code about the RecordSource there.



Hoping it may help,
Vanderghast, Access MVP



I have a main form and sub form and need to find records in both
I have the following code:
open form
' Form_Open
'
'------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err
Me.RecordSource = "service request"
DoCmd.Maximize
DoCmd.ApplyFilter ("Query2")
Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Error$
Resume Form_Open_Exit



click button:

Private Sub Command105_Click()
On Error GoTo Last_Err_command105_Click
Me.RecordSource = "Query1"
DoCmd.Requery
Me.Command105.SetFocus
SendKeys "%HA", False
RunCommand acCmdFind
GoTo Exit_Command105_Click
Exit_Command105_Click:
Exit Sub
Last_Err_command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub

The Query1 allows a search of all data in the main form and sub form.
I need to set rhe record source back to Me.RecordSource = "service
request"
to remove duplicate recorde in the query when the find/replace is
closed
I know rhis an't pretty. but it works. But i need to know how to
"reset
the" the record source when the find/replace box is close.

Any help would maybe keep me employed
thanks
andyc


Thank you for your answer. However, I did not ask the question right.
Let me try again.

I have a form Work order (with the record source of the table Service
request). The form Work order has a sub form (actions with a record
source
of table actions, linked child field of "work order number"). There are
other filters and controls on the forms and this works great for entry of
service calls and actions taken.

All well to this point. Now I have a request to find work orders with
edit
- find. Ok I added the button Command_105 and and used the event
procedure
Onclick to bring up the "customized" find/replace dialog box.. Works fine
BUT will only find in the main form Work order not the sub form actions.
Darn
nothings easy.

So I made the query (query1)

SELECT [service request].*, [It actions].*, *
FROM [service request] LEFT JOIN [It actions] ON [service
request].[Service
Request Number]=[It actions].[Work Order]
WHERE ((([service request].[Type of Service])="IT hardware" Or ([service
request].[Type of Service])="Point of Care" Or ([service request].[Type of
Service])="CPSI"))
ORDER BY [service request].[Service Request Number];

and set the main form (Work order) record source to query1 and added the
text boxs "actions" and "KEY" to the main form. "actions" is hid under
the
sub form, KEY is visible when "action" is not null.

Now find will work for the main form and highlight KEYif the word is found
in action.

But query1 as a record source is not good for data entry. If there are
multiple "actions" there are multiple duplications of the main record and
clicking next record appears to the user not to work.

I don't understand the cover procedure. The Private Sub
Command105_Click()
will set the record source to Query1 and open the find/replace box and
exit
the sub. It will not wait for the find/replace dialog box to close.
I simply need to know when this dialog box closes and if possible opens so
I
can set the main form back to record source = Service request

Hope this is clearer..maybe not?
OK, I'll cease fighting. The users just want to use the find /replace.
I've used the combo box before. I just wanted the "look feel" to be the
same. Gess it can't be done. thanks
 

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