Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change via Window

Status
Not open for further replies.

NotProfessional

Programmer
Sep 9, 2011
9
HR
First of all, hello, I just started to use Clarion 6.3. so I'm not very good at it. I just want to know how to make a Window act like a Update Form, specificaly a Change. Thx.
 
Hi!

To make a Window procedure act as a Update Form, use the Control Template "Save Button" which will add a OK Button to the Window. Add the Table to be saved in the File Schematic & fill out the template prompts. How is this window going to be called - from a Browse or elsewhere? Why? Because in a Browse-Form paradigm it is always the Browse which fetches the record/row for Change/Delete & prime the columns for an Insert. So, if you are calling the Window procedure from somewhere else make sure that ::
1) Retrieve the Record/Row for a Change/Delete and Clear the Record for an Insert
2) Set the GlobalRequest = InsertRecord OR ChangeRecord OR DeleteRecord before calling the Window procedure

Example ::

Code:
CLEAR(FIL:Record)
GlobalRequest = InsertRecord
MyWindowProcedure
IF GlobalResponse = RequestCompleted
   !row added
ELSE
END

CLEAR(FIL:Record)
FIL:ID = 11
GET(MyFile, MyPrimaryKey)
GlobalRequest = ChangeRecord
MyWindowProcedure
IF GlobalResponse = RequestCompleted
   !row changed
ELSE
END

Regards
 
The window is called from a Menubar Item actually. It is a design choice that i rather not change. I did what you said and I got an error:" Adding this record creates a duplicate entry for the key. Primary key."

 
Hi!

Since you want to open the form in Change mode only, could you tell me the name of the Table & it's primary key? Is it a SINGLE row table? Are you using the Legacy or ABC template chain in your application?

Regards
 
TABLE: USER_PROFILE
PK: K_USER
ATTRIBUTES: NAME
PASSWORD

I'm using the ABC template chain.
 
Hi!

Since this is the User Table, I am assuming that there must be multiple rows. So, which row is he supposed to CHANGE when clicks on the Menu Item? What is the purpose of this Menu option - to change password, etc.?

Assuming you want to change the logged in User's profile and the logged in User is stored in GLO:User, the code to be executed BEFORE the procedure is called (you will have to go into Embeds -> Source and find the correct embed in the Frame procedure) would be ::
Code:
CLEAR(USR:Record)
USR:Name = GLO:User
GET(USER_PROFILE, USR:K_USER)
IF ERRORCODE()
   !... handle error ...
   SELECT(?MenuItem) ; CYCLE
ELSE
   GlobalRequest = ChangeRecord
END

Regards

 
The purpose is to let the user change the name or password of the created profile.
 
Hi!

Does "created profile" mean their profile? If so, the code I gave should be fine.

Regards
 
Hi!

Does that mean it works?

An alternative approach is to code it in the Window procedure itself, thereby allowing the Window procedure to be called in its own thread from the Frame.

At WindowManager.Init - After Opening Files embed - add the following code ::

Code:
CLEAR(USR:Record)
USR:Name = GLO:User
IF Access:USER_PROFILE.Fetch(USR:K_USER)
   !... handle error ...
   RETURN LEVEL:Fatal
ELSE
   SELF.Request         = ChangeRecord
   SELF.OriginalRequest = ChangeRecord
END

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top