I am trying to achieve the following on a busy network;
Duplicate a record to a second table, then get the invoice # from the table 2 to table1, the invoice # in table 2 is incremental. My concern is if two users press the button at the same time, is their a change that user 1 will get the invoice # belonging to user 2.
Below is the script I am using.
I tried a test I made two buttons on button #2 I added �sleep(15)� before the �record = target.recno()� line, I opened two instances of Alpha on my computer I reduced the windows so I can work on both at the same time. In the first window I pressed the button with the �sleep(15)� and immediately pressed the other button in the second window the second window refreshed long before the first one, and they both had the correct invoice #.
But will this work the same on the network????
tbl= table.current()
DIM record_data as B
record_data = tbl.record_data_get()
target = table.open(path+"invoice header.dbf")
target.enter_begin()
target.record_data_set(record_data)
target.enter_end(.t.)
record = target.recno()
indx = target.index_primary_put("")
rec = target.fetch_find(record)
if rec >0
newinv = target.invoice_number
tbl.change_begin()
tbl.invoice_number = newinv
tbl.Recored = .t.
tbl.change_end()
cust_id.refresh()
end if
target.close()
Thank you,
Daniel Weiss
Duplicate a record to a second table, then get the invoice # from the table 2 to table1, the invoice # in table 2 is incremental. My concern is if two users press the button at the same time, is their a change that user 1 will get the invoice # belonging to user 2.
Below is the script I am using.
I tried a test I made two buttons on button #2 I added �sleep(15)� before the �record = target.recno()� line, I opened two instances of Alpha on my computer I reduced the windows so I can work on both at the same time. In the first window I pressed the button with the �sleep(15)� and immediately pressed the other button in the second window the second window refreshed long before the first one, and they both had the correct invoice #.
But will this work the same on the network????
tbl= table.current()
DIM record_data as B
record_data = tbl.record_data_get()
target = table.open(path+"invoice header.dbf")
target.enter_begin()
target.record_data_set(record_data)
target.enter_end(.t.)
record = target.recno()
indx = target.index_primary_put("")
rec = target.fetch_find(record)
if rec >0
newinv = target.invoice_number
tbl.change_begin()
tbl.invoice_number = newinv
tbl.Recored = .t.
tbl.change_end()
cust_id.refresh()
end if
target.close()
Thank you,
Daniel Weiss
Comment