[AccessD] List Requery

David Emerson newsgrps at dalyn.co.nz
Wed Jan 7 02:11:39 CST 2009


I tried that with no luck.

I also tried setting the focus to a field and having the on enter 
event trigger the FindRecord but this didn't work either (the field 
gets the cursor, the code fires, the find value is correct but the 
find just doesn't work).

I have ended up having a message box appear when the form is 
opened.  In this case it is not too much of an issue as the form is 
seldom used, and the message warns about the potential consequences 
to changing data using the form, but it would still be nice to know 
why the find wasn't working.

Thanks anyway.

David

At 7/01/2009, you wrote:
>Hi David
>
>You could try putting the first part of your code in the OnOpen 
>event of the form and the second part in the OnLoad event.
>
>/gustav
>
> >>> newsgrps at dalyn.co.nz 07-01-2009 07:17 >>>
>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.
>
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com




More information about the AccessD mailing list