Problem with form_current

S

S Marriott

Hi,

I have an annoying problem with Access 2003 using its form_current
procedure. Within the procedure I am calling a function which updates a
listbox (see code below). However, when I open the form it appears to be
continually 'refreshing' the whole form for 5-6 seconds before stopping. I
have tried this on two PCs and the same problem occurs. This should be
really simple, I have tried removing the event and putting a button on the
form to execute the procedure and that works perfectly, however I really do
need it to be on_current!

Any Ideas?


------------------------
Private Sub Form_Current()
Call UpdateObjects
End Sub

Sub UpdateObjects()

Dim strSQL As String

strSQL = "SELECT [Tbl Objects].ObjectID, [Tbl Objects].ProjectID, [Tbl
Objects].ObjectName, "
strSQL = strSQL & "[Tbl Object Types].ObjectType, [Tbl
Objects].ObjectDateCreated, [Tbl Objects].ObjectLastModified "
strSQL = strSQL & "FROM [Tbl Object Types] INNER JOIN [Tbl Objects] ON [Tbl
Object Types].TypeID = [Tbl Objects].Object_Type "
strSQL = strSQL & "WHERE ((([Tbl Objects].ProjectID)=" & Me.ProjectID & ")
AND (([Tbl Object Types].TypeID)=" & Me.CboObjectType.Value & "));"

Me.lstObjects.RowSource = strSQL
Me.Requery

End Sub

----------------------

TIA


Sarah
 
M

MacDermott

Instead of requerying the form, just requery the listbox.
Requerying the form causes the Form_Current event to fire again.
It's a mercy it stops at all!
 
M

Marshall Barton

S said:
I have an annoying problem with Access 2003 using its form_current
procedure. Within the procedure I am calling a function which updates a
listbox (see code below). However, when I open the form it appears to be
continually 'refreshing' the whole form for 5-6 seconds before stopping. I
have tried this on two PCs and the same problem occurs. This should be
really simple, I have tried removing the event and putting a button on the
form to execute the procedure and that works perfectly, however I really do
need it to be on_current!
------------------------
Private Sub Form_Current()
Call UpdateObjects
End Sub

Sub UpdateObjects()

Dim strSQL As String

strSQL = "SELECT [Tbl Objects].ObjectID, [Tbl Objects].ProjectID, [Tbl
Objects].ObjectName, "
strSQL = strSQL & "[Tbl Object Types].ObjectType, [Tbl
Objects].ObjectDateCreated, [Tbl Objects].ObjectLastModified "
strSQL = strSQL & "FROM [Tbl Object Types] INNER JOIN [Tbl Objects] ON [Tbl
Object Types].TypeID = [Tbl Objects].Object_Type "
strSQL = strSQL & "WHERE ((([Tbl Objects].ProjectID)=" & Me.ProjectID & ")
AND (([Tbl Object Types].TypeID)=" & Me.CboObjectType.Value & "));"

Me.lstObjects.RowSource = strSQL
Me.Requery

End Sub

McDermott put his finger on the problem, but you do not even
need to requery the list box. Setting the RowSource
property will automatically force a requery, so just get rid
of the requery altogether.
 

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