>Can anyone show me how to keep a copy of server lookup table at local. And refresh the local data when server data change.
>
>Thank u.
you can shorten the refresh time or open the same table again on searching...
SET REFRESH TO 60 && refresh data per min.
IF your lookup table is used to check the LastKey entry.
This is better to reopen the data to check it on.
because there are some code delay time even another application not yet update the Lookup table.
From The Below example, you will see the update lookup table coding is quite last action to do.
during the time, maybe some other machine also ask for adding records and
got problem on duplicate KEY order_NO
Well, it also use another method to ensure the Key adding is NEW one.
Lookup Table here is good if your key adding is in the middle.
Such as there are some ORDER_NO in table are P3456, V1234....
and now use ORDER_NO with R2345
IF take the last # of TABLE, it will give you Vxxxx, which is NOT the real one you needed.
Maybe you need the one is R2866 then Generate R2867 ...
USE orders AGAIN IN 0 ORDER TAG ORDER_NO ALIAS chkOrders
CurLastKey = LookupOrds.ORDER_NO
NextKey = THISFORM.GenNewKey(CurLastKey)
RealNew = .F.
SELECT chkOrders
Do While !RealNew
LOCATE FOR ORDER_NO = NextKey
IF FOUND()
NextKey = THISFORM.GenNewKey(NextKey)
CONTINUE
ELSE
RealNew = .T.
ENDIF
EndDO
REPLACE ORDERS.ORDER_NO With NextKEY
IF TABLEUPDATE(.T.) = .F.
MessageBox([Fail to Add records], 16, [Add Orders])
ELSE
REPLACE chkOrders.ORDER_NO with NextKey
MessageBox([Success in Adding Records], 64, [Add Orders])
ENDIF
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.