[AccessD] List Requery

David Emerson newsgrps at dalyn.co.nz
Wed Jan 7 00:17:16 CST 2009


I have an adp form that has a list on it.  When an item is selected 
from the first list then the main record on the form should show the 
fields from the list (it has the same table as its source).  This 
works well once the form is open.

What I want to do is when the form is first opened that the first 
item in the first list is selected and the second list updated using 
this selection.

Here is the code I have (I have removed the error trapping):

Private Sub Form_Load()

     ' MsgBox "Selecting first entry"
     Me!lstDailyEntry.RowSource = "EXEC dbo.splstDailyEntry '" & 
Forms!frmMainMenu!LocationFilter & "'"
     Me!lstDailyEntry.Requery
     Me!lstDailyEntry = Me!lstDailyEntry.ItemData(1)
     Call lstDailyEntry_AfterUpdate

End Sub

Private Sub lstDailyEntry_AfterUpdate()

     Me!txtEntryLogSetID.Enabled = True
     Me!txtEntryLogSetID.SetFocus
     DoCmd.FindRecord Nz(Me!lstDailyEntry.Column(0), 0)
     DoCmd.GoToControl "lstDailyEntry"
     Me!txtEntryLogSetID.Enabled = False
     Me!lstDailyEntryRecord.RowSource = "EXEC 
dbo.splstDailyEntryRecord " & Me!txtEntryLogSetID
     Me!lstDailyEntryRecord.Requery

End Sub

The first item in list one is selected but the main record is not updated.

If I put a breakpoint at the start of the Load event and F8 through 
the code then the main record updates correctly.
If I unrem the msgbox at the start of the Load Event then the main 
record updates correctly.  But if I leave the code to run by itself 
then the main record doesn't get updated.  I have tried putting a For 
Next Loop at the start of the Load event but this doesn't solve the problem.

It seems to be a timing issue but I am not sure how to trigger it 
without user intervention.





More information about the AccessD mailing list