Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataList refill

Status
Not open for further replies.

hansu

Programmer
Mar 12, 2002
89
Hi

I have a strange problem with refilling a DataList:
I have a form where the user can update entries in a table. Once he has done that I want to refill a datalist which is based on a recordset (rstMem) from that table in another form (frmRes).

frmRes.rstMem.Requery
frmRes.dblstMembers.ReFill

When I run the project the DataList doesn't refill but when I run it in debug mode step by step it works perfectly. Has anyone else faced this problem?
 
I think the problem may be that the two events run one after the other, without the first event finishing, prior to the second one starting.

Try placing a loop function between the two, so that it waits for 1 sec, and then performs the other operation. This isn't the correct way to solve the problem, but at least it will point you in the right direction.

Another way is to make the requery a function that returns true/false. Then place a DoEvents loop after the first statement, and loop until this statement returns true, and then perform the second task. If you chose this method, make sure you put a time limit on how long the loop waits for a true statement. For example, if it waits for a true statement, but the function never completes, after 5 seconds give up waiting and raise an error.

I'm sure someone in this forum will be able to explain the order in which things are called and complete, and which events must complete before the next starts etc.

Goood luck

BB
 
Thank you BiggerBrother for your suggestions. It really seems to be a problem of the order in which the code is processed. I now realized that it is not a problem of the requiry statement because that works. It's the insert or update statement before that's not executed in runtime mode although it's executed in debug mode.
 
So, of the 2 lines of code you have posted, you know the first line works, but the second doesn't refill? Is that what you mean?

BB
 
Hi BB

What actually happens is:
With the first form I mentionend the user inserts records into a table. The datalist on the form frmRes is filled with records (rstMem) from that table.
It seems that in runtime mode the requiry statement is executed before the insert statement because it retrieves only the records which were in the table before the insert.
So now I replaced the requiry statement by:
Code:
frmRes.rstMem.Close
frmRes.rstMem.Open frmRes.strMem, cnLodging, adOpenStatic, adLockReadOnly
frmRes.dblstMembers.ReFill
That retrieves the correct number of records but the DataList doesn't refill.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top