If else subform reference access 2007

A

Asib

Hello all. This is my situation. I have a main form [frmMain] with a tab
control. the tab control has 5 tabs all with there own subform. I have found
myself having to use a workaround for the fact that the subform is not
isolated (i have read allen brownes bug description and that is what im up
against)from the mainforms remove filter button docmd.showallrecords(Code
below). Basicly when i push the button i was removing the filter of the main
form. which worked fine.But now with the 5th tabs subform being set to data
entry, when i use the showallrecords or me.filter = false it is setting the
data entry subform to the first record in the table.
What i am now trying to accomplish is when the user clicks the remove
filter btn the code checks to see what the current subform is and removes the
filter without removeing focus from the subform that is curently being
viewed. I am rather new to VBA and cant seem to find the right syntax for the
code. Any and all help is greatly appretiated. Thanks Asib




Private Sub btnRemoveFilter_Click()
On Error GoTo Err_handler

'DoCmd.Echo False
DoCmd.ShowAllRecords

If Me.[sbfrmNotes].Screen.ActiveForm Then
Me![sbfrmNotes].SetFocus
DoCmd.GoToRecord , , acNewRec

Else


'Forms![frmMain].SetFocus
Me!Screen.ActiveForm.SetFocus
Me.[FltItemNumber].Value = Null
Me.[FltDescription].Value = Null
Me.[FltPagenumber].Value = Null
Forms![frmMain]!FltItemNumber.SetFocus
'DoCmd.Echo True
End If

Exit_Handler:
Exit Sub

Err_handler:
If Err.Number <> 0 Then 'Ignore "Report cancelled" error.
MsgBox "" & Err.Number & " - " & Err.Description, , "Search"
End If
Resume Exit_Handler

End Sub
 
G

Graham Mandeno

Hi Asib

I would use Me.FilterOn = False in preference to DoCmd.ShowAllRecords.

If the problem is still occurring when using the FilterOn property, then you
could try explicitly setting the subform's DataEntry property after clearing
the filter:

Me.[sbfrmNotes].Form.DataEntry = True

You don't need to set focus to any particular form or subform in order to
manipulate its properties.
 
A

Asib

Hi Graham, I did have to reset the data entry forms FilterOn Property. But
the EchoOn-EchoOff Makes it look seemless to the end user. Thanks for the
help. I havent been able to dedicate any large chunks of time to this lately
and i think by brain is getting soft. I could have sworn i tried your
suggestion previously. But thanks again. Much appretiated.

Graham Mandeno said:
Hi Asib

I would use Me.FilterOn = False in preference to DoCmd.ShowAllRecords.

If the problem is still occurring when using the FilterOn property, then you
could try explicitly setting the subform's DataEntry property after clearing
the filter:

Me.[sbfrmNotes].Form.DataEntry = True

You don't need to set focus to any particular form or subform in order to
manipulate its properties.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Asib said:
Hello all. This is my situation. I have a main form [frmMain] with a tab
control. the tab control has 5 tabs all with there own subform. I have
found
myself having to use a workaround for the fact that the subform is not
isolated (i have read allen brownes bug description and that is what im up
against)from the mainforms remove filter button docmd.showallrecords(Code
below). Basicly when i push the button i was removing the filter of the
main
form. which worked fine.But now with the 5th tabs subform being set to
data
entry, when i use the showallrecords or me.filter = false it is setting
the
data entry subform to the first record in the table.
What i am now trying to accomplish is when the user clicks the remove
filter btn the code checks to see what the current subform is and removes
the
filter without removeing focus from the subform that is curently being
viewed. I am rather new to VBA and cant seem to find the right syntax for
the
code. Any and all help is greatly appretiated. Thanks Asib




Private Sub btnRemoveFilter_Click()
On Error GoTo Err_handler

'DoCmd.Echo False
DoCmd.ShowAllRecords

If Me.[sbfrmNotes].Screen.ActiveForm Then
Me![sbfrmNotes].SetFocus
DoCmd.GoToRecord , , acNewRec

Else


'Forms![frmMain].SetFocus
Me!Screen.ActiveForm.SetFocus
Me.[FltItemNumber].Value = Null
Me.[FltDescription].Value = Null
Me.[FltPagenumber].Value = Null
Forms![frmMain]!FltItemNumber.SetFocus
'DoCmd.Echo True
End If

Exit_Handler:
Exit Sub

Err_handler:
If Err.Number <> 0 Then 'Ignore "Report cancelled" error.
MsgBox "" & Err.Number & " - " & Err.Description, , "Search"
End If
Resume Exit_Handler

End Sub
 

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