Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
'Save' as 'Revert'
Message
From
14/03/2001 19:18:18
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
14/03/2001 17:01:45
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00485071
Message ID:
00485105
Views:
7
Chuck,

(Note use of < pre > and < /pre > (without spaces) to format code.)

What table are you doing the INDEXSEEK() on? Person or something else? Assuming that you are in the Person table, then I have the following observations:

Please read carefully about the difference between SEEK() and INDEXSEEK(). You are not passing the lMovePointer parameter so you are very likely on the wrong record when you test IF Person.ID = m. ID....

Secondly, it looks like you want to:
1. Do nothing if the Name and Logon for the ID matches the ones in the table
2. Pick up the values in the table if the Name or Logon are different from the ones in the table
3. Do something else entirely if you didn't find the ID in the table.

Looks like you need the following:
IF INDEXSEEK(m.ID, .T., "Person", "ID")
    Messagebox('This Person ID is already in the database.'+CHR(13)+ ;
        'Duplicate Records will not be saved!',64)

    *!* m.ID is already correct. 
    *!* "Refresh" Name and Logon, even if they are the same
    *!* who cares if they are already the same
    m.Name = Person.Name
    m.Logon = Person.Logon
ELSE
    *!* Do whatever you do with a new record
ENDIF
A more OOP way is to make these variables properties of your form rather than memory variables, since that solves problems of variables going out of scope.
>IF INDEXSEEK(m.id)
>	IF person.id = m.id AND ;
>		person.name = m.name AND ;
>		person.logon = m.logon
>			wait window 'Same stuff'
>	ELSE
>		Messagebox('This Person ID is already in the database.'+CHR(13)+ ;
>					'Duplicate Records will not be saved!',64)
>		m.id = person.id
>		m.name = person.name
>		m.logon = person.logon
>	ENDIF
>ELSE
>
>then the rest of the code does it's thing (as 'Add' or 'Edit') and refreshes...
>
>My question is since this above code works (in 'Save' ClickEvent), I feel there is a better way to do this. What is happening is if the user click the 'Edit' button, the only two buttons become enabled ('Save' and 'Esc', 'Esc' works like 'Revert' but they want to call it like that). Now, if the user click 'Esc', it goes back just the way it was before (disables and enables all other stuff). If the user click 'Save', but didn't change anything, I want to just go back just like 'Esc' does. The code above is where this catches this part, so there is nothing updating the tables yet, the updating occurs just right after this ELSE. I am using memory variable, so what does VFP 6.0 have for that, or that's it? I know it's little weird, but we know that's part of programming life.
>
>Chuck
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform