Joe Crescenzi
Programmer
Here's something fun that I stumbled into that I decided was worthy of sharing for those who may be curious.
When you open a table using USE... NOUPDATE, any subsequent USE commands with AGAIN and ALIAS may, or may not end up inheriting the Read Only / NOUPDATE status, depending on how the first USE command was called.
Here's an example.
The result here will be that you will have four open tables, with the one called "ReadOnlyVersion" being the only one that is open in Read Only mode.
However, if you open the tables with the NOUPDATE line first, ALL of the tables will end up Read Only.
Here's the result.
I discovered this accidentally when I decided to open some tables in NOUPDATE on a screen that didn't allow editing, then without realizing that later in the session I open another form that DOES allow edits, and since the previous table was already open in ReadOnly, the second form didn't allow edits.
When you open a table using USE... NOUPDATE, any subsequent USE commands with AGAIN and ALIAS may, or may not end up inheriting the Read Only / NOUPDATE status, depending on how the first USE command was called.
Here's an example.
Code:
CLOSE DATABASES
USE testtable IN 0 AGAIN SHARED ALIAS "Regular"
USE testtable IN 0 AGAIN SHARED ALIAS "ReadOnlyVersion" NOUPDATE
USE testtable IN 0 AGAIN SHARED ALIAS "Regular2"
USE testtable IN 0 AGAIN SHARED ALIAS "Regular3"
The result here will be that you will have four open tables, with the one called "ReadOnlyVersion" being the only one that is open in Read Only mode.
Code:
Select area: 4, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF Alias: REGULAR3
Select area: 3, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF Alias: REGULAR2
Select area: 2, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF (Readonly) Alias: READONLYVERSION
Currently Selected Table:
Select area: 1, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF Alias: REGULAR
However, if you open the tables with the NOUPDATE line first, ALL of the tables will end up Read Only.
Code:
CLOSE DATABASES
USE testtable IN 0 AGAIN SHARED ALIAS "ReadOnlyVersion" NOUPDATE
USE testtable IN 0 AGAIN SHARED ALIAS "Regular"
USE testtable IN 0 AGAIN SHARED ALIAS "Regular2"
USE testtable IN 0 AGAIN SHARED ALIAS "Regular3"
Here's the result.
Code:
Select area: 4, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF (Readonly) Alias: REGULAR3
Select area: 3, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF (Readonly) Alias: REGULAR2
Select area: 2, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF (Readonly) Alias: REGULAR
Currently Selected Table:
Select area: 1, Table in Use: C:\SOURCECODE\CARTPRO.NEW\TESTTABLE.DBF (Readonly) Alias: READONLYVERSION
I discovered this accidentally when I decided to open some tables in NOUPDATE on a screen that didn't allow editing, then without realizing that later in the session I open another form that DOES allow edits, and since the previous table was already open in ReadOnly, the second form didn't allow edits.