Hide the REPLACE tab problem

G

Guest

Hello wise ones,

Access 2003 user on WinXP. I am using the code below to surpress the
REPLACE tab in the acCmdFind command.
The btnFind control is located in the form header. I have the main form
with a tabbed subform. The code below works fine if the cursor is on the
first tab, but if I click on subsequent tabs, it does not surpress the
replace tab. It does display the msgbox in the code, so it does fire.
Any thoughts? Is this just a corrupt form?



'***** START OF CODE SAMPLE ************

On Error GoTo Err_btnFind_Click


Screen.PreviousControl.SetFocus
If Me.Dirty Then
Me.Dirty = False
End If

Me.AllowEdits = False 'Suppress REPLACE tab
MsgBox "allow edits false" 'for testing purposes
DoCmd.RunCommand acCmdFind
Me.AllowEdits = True 'Restore state
Exit Sub

Exit_btnFind_Click:
Exit Sub

Err_btnFind_Click:
If Err.Number = 2137 Then 'user clicked FIND on a Add new record recordset
MsgBox "Can't use FIND function now."
Else
MsgBox "Form Error #" & Err.Number & ", Notify Database Admin. "
End If

Me.AllowEdits = True
'MsgBox Err.Description
Resume Exit_btnFind_Click

'***** END OF CODE SAMPLE ************

Thank you,
 
R

Rob Parker

Hi David,

This is just a suggestion, since you haven't fully described your situation.

If the first tab on your form is displaying the main recordset, and the
other tabs are displaying subforms based on/linked to that recordset (and
that's a fairly common way of setting things up), then the problem is
probably that you need to set the AllowEdits property for the subform(s).
You can do this adding another line of code such as this to set the
AllowEdits property of the subforms when you set the main form:
...
Me.AllowEdits = False 'Suppress REPLACE tab in main form
Me.NameOfSubFormControl.Form.AllowEdits = False 'Suppress REPLACE in
subform
...

And I've learnt something new too - that AllowEdits (False) disables the
Replace functionality. Never tried it, and it seems logical - but if that's
the case, why is it like that in Access <grin>

HTH,

Rob
 
G

Guest

Perfect Thank you.
Your assumption was corret. I have a subform on each tab page. I added
reference to the subforms and it worked like a charm.
 

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

Similar Threads


Top