Access 2007 form properties

R

RayV

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
 
T

Tim Johnson

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.
 
R

RayV

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.







- 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.
 
T

Tim Johnson

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.)?
 
R

RayV

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.)?








- 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...
 
R

RayV

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?
 

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