mkrausnick
Programmer
I have client company table and a separate client contact table.
The contact data entry form has:
1. A listbox showing all companies
2. A second listbox showing all contacts for one company
3. All the contact information textbox fields for the contact, bound to the contacts table fields.
4. Buttons: NEW, SAVE, CLOSE.
The user first clicks the company in the company listbox, which sets a filter on the contacts table, causing the second listbox to display contacts for only that company. Then the user clicks the contact to be modified in the second listbox and the data for that contact may be modified in the data entry section.
Buffering for the contacts table is set to '3'-Optimistic Row.
I have the following "CHECKMODIFIED" function that is called from <companylistbox.click>, CLOSE, and the form's QUERYUNLOAD event:
Now, if the user modifies a field and then closes the form by either the CLOSE button or clicking the "X", GETFLDSTATE correctly returns '2' for the modified field, and the messagebox is displayed.
But if the user modifies a field and then clicks a different company, although the CHECKMODIFIED function is called, GETFLDSTATE returns '1' for all fields including the one that was modified.
The call structure is the same in all three places:
This has me stumped. Why doesn't GETFLDSTATE always return '2' if a field is changed?
Mike Krausnick
Dublin, California
The contact data entry form has:
1. A listbox showing all companies
2. A second listbox showing all contacts for one company
3. All the contact information textbox fields for the contact, bound to the contacts table fields.
4. Buttons: NEW, SAVE, CLOSE.
The user first clicks the company in the company listbox, which sets a filter on the contacts table, causing the second listbox to display contacts for only that company. Then the user clicks the contact to be modified in the second listbox and the data for that contact may be modified in the data entry section.
Buffering for the contacts table is set to '3'-Optimistic Row.
I have the following "CHECKMODIFIED" function that is called from <companylistbox.click>, CLOSE, and the form's QUERYUNLOAD event:
Code:
LOCAL lModified, nResult, nFieldNum
lModified = .F.
SELECT provcont
FOR nFieldNum = 1 TO FCOUNT("provcont") && Go through fields, checking for any field that's been modified.
IF GETFLDSTATE(nFieldNum,"provcont") = 2
lModified = .T.
EXIT
ENDIF
ENDFOR
IF lModified
nResult = MESSAGEBOX;
("Information for the current contact has been modified. Save these changes?", ;
3+32+512, "Save Changes")
DO CASE
CASE nResult = 7 && Save=No
TABLEREVERT (.F.)
RETURN 0
CASE nResult = 6 && Save=Yes
TABLEUPDATE(0,.T.,"provcont")
RETURN 0
OTHERWISE
RETURN -1 && Return to form
ENDCASE
ENDIF
RETURN 0
Now, if the user modifies a field and then closes the form by either the CLOSE button or clicking the "X", GETFLDSTATE correctly returns '2' for the modified field, and the messagebox is displayed.
But if the user modifies a field and then clicks a different company, although the CHECKMODIFIED function is called, GETFLDSTATE returns '1' for all fields including the one that was modified.
The call structure is the same in all three places:
Code:
IF Thisform.Checkmodified() < 0 && Returns -1 if user clicks CANCEL
NODEFAULT
ELSE
.
. Do some other stuff
.
ENDIF
Mike Krausnick
Dublin, California