Access 2007 form properties

  • Follow


We just upgraded(?) to Access 2007 and the first thing I have come
across is this:
I have a simple continuous form where the query is based on the value
in the control 'box_district'.  'box_district' is in the form header.
I have the detail of the form hidden until 'box_district' gets
updated.  This code bombs at the asterisked line but it is because the
detail does not become visible as it should based on the third line.

Was something changed that would prevent 'me.detail.visible = true'
from working?

Private Sub box_district_AfterUpdate()
    Me.Requery
    Me.Detail.Visible = True
    numtouse = DCount("fldSchYear7", "tblYear")
    For i = 1 To numtouse
        If Me.boxfldSchYear7.Value = Me.box_year.Value Then
            For j = i To numtouse
                i = numtouse + 1
                If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
Then
                    j = numtouse + 1
 *                  Me!boxdol.SetFocus
                Else
                    Me.Recordset.MoveNext
                End If
            Next j
        Else
            Me.Recordset.MoveNext
        End If
    Next i
End Sub
0
Reply RayV 12/19/2007 2:52:39 AM

Hi Ray,

I've run into quite a few issues with the setfocus command, myself.

First of all, have you tried removing the setfocus command and ensuring that 
everything works properly without it?

Also, have you tried waiting to set focus to boxdol until the very end?  It 
would require an extra 'if' statement, but might work.  I'd try removing the 
setfocus line; after the line with the 'Next i' statement, I'd try the 
following code:

if me.detail.visible = true then
     Me!boxdol.setfocus
end if

I hope that helps.

"RayV" wrote:

> We just upgraded(?) to Access 2007 and the first thing I have come
> across is this:
> I have a simple continuous form where the query is based on the value
> in the control 'box_district'.  'box_district' is in the form header.
> I have the detail of the form hidden until 'box_district' gets
> updated.  This code bombs at the asterisked line but it is because the
> detail does not become visible as it should based on the third line.
> 
> Was something changed that would prevent 'me.detail.visible = true'
> from working?
> 
> Private Sub box_district_AfterUpdate()
>     Me.Requery
>     Me.Detail.Visible = True
>     numtouse = DCount("fldSchYear7", "tblYear")
>     For i = 1 To numtouse
>         If Me.boxfldSchYear7.Value = Me.box_year.Value Then
>             For j = i To numtouse
>                 i = numtouse + 1
>                 If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
> Then
>                     j = numtouse + 1
>  *                  Me!boxdol.SetFocus
>                 Else
>                     Me.Recordset.MoveNext
>                 End If
>             Next j
>         Else
>             Me.Recordset.MoveNext
>         End If
>     Next i
> End Sub
> 
0
Reply Utf 12/19/2007 3:45:00 AM


On Dec 18, 7:45 pm, Tim Johnson <TimJohn...@discussions.microsoft.com>
wrote:
> Hi Ray,
>
> I've run into quite a few issues with the setfocus command, myself.
>
> First of all, have you tried removing the setfocus command and ensuring that
> everything works properly without it?
>
> Also, have you tried waiting to set focus to boxdol until the very end?  It
> would require an extra 'if' statement, but might work.  I'd try removing the
> setfocus line; after the line with the 'Next i' statement, I'd try the
> following code:
>
> if me.detail.visible = true then
>      Me!boxdol.setfocus
> end if
>
> I hope that helps.
>
>
>
> "RayV" wrote:
> > We just upgraded(?) to Access 2007 and the first thing I have come
> > across is this:
> > I have a simple continuous form where the query is based on the value
> > in the control 'box_district'.  'box_district' is in the form header.
> > I have the detail of the form hidden until 'box_district' gets
> > updated.  This code bombs at the asterisked line but it is because the
> > detail does not become visible as it should based on the third line.
>
> > Was something changed that would prevent 'me.detail.visible = true'
> > from working?
>
> > Private Sub box_district_AfterUpdate()
> >     Me.Requery
> >     Me.Detail.Visible = True
> >     numtouse = DCount("fldSchYear7", "tblYear")
> >     For i = 1 To numtouse
> >         If Me.boxfldSchYear7.Value = Me.box_year.Value Then
> >             For j = i To numtouse
> >                 i = numtouse + 1
> >                 If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
> > Then
> >                     j = numtouse + 1
> >  *                  Me!boxdol.SetFocus
> >                 Else
> >                     Me.Recordset.MoveNext
> >                 End If
> >             Next j
> >         Else
> >             Me.Recordset.MoveNext
> >         End If
> >     Next i
> > End Sub- Hide quoted text -
>
> - Show quoted text -

The set focus isn't really the problem.  The problem is
'Me.Detail.Visible=True' doesn't make the detail of the form visible.
Then since the detail of the form is hidden Me.boxdol.SetFocus bombs
because boxdol is in the hidden detail.

If I make everything visible from the get go the rest of the code
works including the SetFocus.  When I go to the debugger and hover
over 'Me.Detail.Visible=True' I see this in the yellow box that
appears 'Me.Detail.Visible=False'.

I'm thinking they must have changed how the 'Me' works and Access is
making something else visible at run time but then checking the form
detail when debugging.  I even tried changing the statement to
implicity refer to the forms detail but no difference.
0
Reply RayV 12/19/2007 11:07:43 AM

Ray, sorry for my misunderstanding.

I have been using Access 07 for about 6 months now and can confirm that they 
have not changed how 'Me' works.  

I have tried several times and been unable to duplicate your error using 
this OnClick method.  Have you tried testing variaitons of the code (e.g. 
pulling out all of the code after the me.detail.visible = true line and 
seeing how it works, trying a different event trigger, etc.)?

"RayV" wrote:

> On Dec 18, 7:45 pm, Tim Johnson <TimJohn...@discussions.microsoft.com>
> wrote:
> > Hi Ray,
> >
> > I've run into quite a few issues with the setfocus command, myself.
> >
> > First of all, have you tried removing the setfocus command and ensuring that
> > everything works properly without it?
> >
> > Also, have you tried waiting to set focus to boxdol until the very end?  It
> > would require an extra 'if' statement, but might work.  I'd try removing the
> > setfocus line; after the line with the 'Next i' statement, I'd try the
> > following code:
> >
> > if me.detail.visible = true then
> >      Me!boxdol.setfocus
> > end if
> >
> > I hope that helps.
> >
> >
> >
> > "RayV" wrote:
> > > We just upgraded(?) to Access 2007 and the first thing I have come
> > > across is this:
> > > I have a simple continuous form where the query is based on the value
> > > in the control 'box_district'.  'box_district' is in the form header.
> > > I have the detail of the form hidden until 'box_district' gets
> > > updated.  This code bombs at the asterisked line but it is because the
> > > detail does not become visible as it should based on the third line.
> >
> > > Was something changed that would prevent 'me.detail.visible = true'
> > > from working?
> >
> > > Private Sub box_district_AfterUpdate()
> > >     Me.Requery
> > >     Me.Detail.Visible = True
> > >     numtouse = DCount("fldSchYear7", "tblYear")
> > >     For i = 1 To numtouse
> > >         If Me.boxfldSchYear7.Value = Me.box_year.Value Then
> > >             For j = i To numtouse
> > >                 i = numtouse + 1
> > >                 If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
> > > Then
> > >                     j = numtouse + 1
> > >  *                  Me!boxdol.SetFocus
> > >                 Else
> > >                     Me.Recordset.MoveNext
> > >                 End If
> > >             Next j
> > >         Else
> > >             Me.Recordset.MoveNext
> > >         End If
> > >     Next i
> > > End Sub- Hide quoted text -
> >
> > - Show quoted text -
> 
> The set focus isn't really the problem.  The problem is
> 'Me.Detail.Visible=True' doesn't make the detail of the form visible.
> Then since the detail of the form is hidden Me.boxdol.SetFocus bombs
> because boxdol is in the hidden detail.
> 
> If I make everything visible from the get go the rest of the code
> works including the SetFocus.  When I go to the debugger and hover
> over 'Me.Detail.Visible=True' I see this in the yellow box that
> appears 'Me.Detail.Visible=False'.
> 
> I'm thinking they must have changed how the 'Me' works and Access is
> making something else visible at run time but then checking the form
> detail when debugging.  I even tried changing the statement to
> implicity refer to the forms detail but no difference.
> 
0
Reply Utf 12/20/2007 1:33:02 AM

On Dec 19, 8:33 pm, Tim Johnson <TimJohn...@discussions.microsoft.com>
wrote:
> Ray, sorry for my misunderstanding.
>
> I have been using Access 07 for about 6 months now and can confirm that they
> have not changed how 'Me' works.  
>
> I have tried several times and been unable to duplicate your error using
> this OnClick method.  Have you tried testing variaitons of the code (e.g.
> pulling out all of the code after the me.detail.visible = true line and
> seeing how it works, trying a different event trigger, etc.)?
>
>
>
> "RayV" wrote:
> > On Dec 18, 7:45 pm, Tim Johnson <TimJohn...@discussions.microsoft.com>
> > wrote:
> > > Hi Ray,
>
> > > I've run into quite a few issues with the setfocus command, myself.
>
> > > First of all, have you tried removing the setfocus command and ensuring that
> > > everything works properly without it?
>
> > > Also, have you tried waiting to set focus to boxdol until the very end?  It
> > > would require an extra 'if' statement, but might work.  I'd try removing the
> > > setfocus line; after the line with the 'Next i' statement, I'd try the
> > > following code:
>
> > > if me.detail.visible = true then
> > >      Me!boxdol.setfocus
> > > end if
>
> > > I hope that helps.
>
> > > "RayV" wrote:
> > > > We just upgraded(?) to Access 2007 and the first thing I have come
> > > > across is this:
> > > > I have a simple continuous form where the query is based on the value
> > > > in the control 'box_district'.  'box_district' is in the form header.
> > > > I have the detail of the form hidden until 'box_district' gets
> > > > updated.  This code bombs at the asterisked line but it is because the
> > > > detail does not become visible as it should based on the third line.
>
> > > > Was something changed that would prevent 'me.detail.visible = true'
> > > > from working?
>
> > > > Private Sub box_district_AfterUpdate()
> > > >     Me.Requery
> > > >     Me.Detail.Visible = True
> > > >     numtouse = DCount("fldSchYear7", "tblYear")
> > > >     For i = 1 To numtouse
> > > >         If Me.boxfldSchYear7.Value = Me.box_year.Value Then
> > > >             For j = i To numtouse
> > > >                 i = numtouse + 1
> > > >                 If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
> > > > Then
> > > >                     j = numtouse + 1
> > > >  *                  Me!boxdol.SetFocus
> > > >                 Else
> > > >                     Me.Recordset.MoveNext
> > > >                 End If
> > > >             Next j
> > > >         Else
> > > >             Me.Recordset.MoveNext
> > > >         End If
> > > >     Next i
> > > > End Sub- Hide quoted text -
>
> > > - Show quoted text -
>
> > The set focus isn't really the problem.  The problem is
> > 'Me.Detail.Visible=True' doesn't make the detail of the form visible.
> > Then since the detail of the form is hidden Me.boxdol.SetFocus bombs
> > because boxdol is in the hidden detail.
>
> > If I make everything visible from the get go the rest of the code
> > works including the SetFocus.  When I go to the debugger and hover
> > over 'Me.Detail.Visible=True' I see this in the yellow box that
> > appears 'Me.Detail.Visible=False'.
>
> > I'm thinking they must have changed how the 'Me' works and Access is
> > making something else visible at run time but then checking the form
> > detail when debugging.  I even tried changing the statement to
> > implicity refer to the forms detail but no difference.- Hide quoted text -
>
> - Show quoted text -

OK so what about the order of events for controls.  I have an event
for box_district when it gets focus to hide the form detail then after
update event for box_district makes the detail visible.  Maybe the got
focus event is recurring and rehiding the detail after it updates...
0
Reply RayV 12/20/2007 2:05:30 PM

On Dec 18, 9:52 pm, RayV <NunyaBiz...@comcast.net> wrote:
> We just upgraded(?) to Access 2007 and the first thing I have come
> across is this:
> I have a simple continuous form where the query is based on the value
> in the control 'box_district'.  'box_district' is in the form header.
> I have the detail of the form hidden until 'box_district' gets
> updated.  This code bombs at the asterisked line but it is because the
> detail does not become visible as it should based on the third line.
>
> Was something changed that would prevent 'me.detail.visible = true'
> from working?
>
> Private Sub box_district_AfterUpdate()
>     Me.Requery
>     Me.Detail.Visible = True
>     numtouse = DCount("fldSchYear7", "tblYear")
>     For i = 1 To numtouse
>         If Me.boxfldSchYear7.Value = Me.box_year.Value Then
>             For j = i To numtouse
>                 i = numtouse + 1
>                 If IsNull(Me.boxdol.Value) And IsNull(Me.boxper.Value)
> Then
>                     j = numtouse + 1
>  *                  Me!boxdol.SetFocus
>                 Else
>                     Me.Recordset.MoveNext
>                 End If
>             Next j
>         Else
>             Me.Recordset.MoveNext
>         End If
>     Next i
> End Sub

This fix seems wierd to me but it works.
when box_district is updated it is supposed to make the detail
visible.  What must be happening is the after update event starts to
run which finds the next null record for data entry.  While this event
is running the event for box_district getting the focus runs which
hides the detail.  I can get everything to work the way it used to by
putting Me.boxdol.setfocus immediately after the make detail visible
line.

It worked fine as above in '03 but not in '07.  Is '07 that much
faster that a got focus event runs before an after update event
finishes?
0
Reply RayV 12/20/2007 2:35:28 PM

5 Replies
300 Views

(page loaded in 0.8 seconds)

Similiar Articles:













8/1/2012 6:06:15 AM


Reply: