Subject | TIB_LOOKUPCOMBO REVISITED |
---|---|
Author | hadji@logos.cy.net |
Post date | 2001-08-23T04:46:47Z |
Disregard previous one,CAPS due to cut and paste sorry for this.
My original message.
I am sorry for the misundestanding.I was not intending to do that at
all.Apologies.
My message is
I have a form with two TIB_QUERY objects,two IB_DATASOURCES and two
IB_TRANSACTIONS and also one connection.One query is for the PROJECT
table and the other for the PROJECTTYPE table.I also attach to each
two TIB_TRANSACTION .The field 'TYPE' in the PROJECT table is looked
from the PROJECTTYPE table.I have set up a TIB_LOOKUPCOMBO as
described in the GETTING STARTED GUIDE FOR IBOJECTS.Everything is
working fine as far as the TIB_LOOKUPCOMBO box is concerned but
i have noticed the following strange behaviour,i am sure i am doing
something wrong becase i am new to IBOBJECTS and client/server.
a.When I scroll the PROJECTTYPE TABLE using a TIB_GRID i have noticed
that sometimes a record is inserted in the PROJECT table and the
table gets into edit mode.
b. The value of the 'TYPE' field of the current record in the
PROJECT table changes value to correspond to the current record
of the PROJECTTYPES table current record and gets into edit mode
Please help me to undestand what Iam doing wrong.Also please tell me
if its a good policy to use a separate transaction TIB_TRANSACTION
for each table.
Again I apologise for the CAPS.
Thanks
COSTAS
My additional information
Thank you all for the answers.To undestand better my problem see
below
My project has 4 forms.The main form,the data module,the projects
detail form and the projects type form.The last two forms contain
each one IB_GRID and several IB_EDIT controls.
The data module contains the following.
1.TIB_QUERY(qrCONCUST) for the projects table(concust) with SQL as
below
'select * from concust'
2.TIB_QUERY (qrPROCATEGORIES)for the project types table(protypes)
with SQL as below
'select * from protypes'
3.Two TIB_DATASOURCES(dsCONCUST,qryPROCATEGORIES) connected to above
4.One TIB_CONNECTION(cnCRAMS) pointing to the database.
5.One TIB_TRANSACTION(tsCRAMS).
TIB_QUERIES ib_connections are set to cnCRAMS and ib_transactions
to tsCRAMS.
On the projects form i have buttons for editing the data and adding
data.
eg. the code for the ADD button is
DATA.qryCONCUST.Insert;
BTOK.Visible:=TRUE;
BTCANC.VISIBLE:=TRUE;
BTOK,BTCANC buttons are for commiting the changes of insert or
discarting them
The code for the BTOK button is
IF (IB_EDIT1.Text='') OR (LENGTH(IB_EDIT1.Text)<5) THEN
BEGIN
SHOWMESSAGE('WRONG CODE!!');
EXIT;
END;
DATA.qryCONCUST.Post;
DATA.tsCRAMS.Commit;
DATA.qryCONCUST.CLOSE;
DATA.qryCONCUST.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
The code for the BTCANC button is
DATA.qryCONCUST.Cancel;
DATA.tsCRAMS.Rollback;
DATA.qryCONCUST.CLOSE;
DATA.qryCONCUST.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
Similar controls and buttons exist for the projecttypes form
Everything works ok upto now.
When in the projects form i drop a TIB_LOOKUPCOMBO and set it up
my problems start.
Settings for the tib_lookupcombo
datasource : dsPROTYPES
custompopup :ib_grid2 (pointing to dsPROCATEGORIES)
Displayfield:Category (primary key in PROTYPES)
Settings for the qryPROCATEGORIES
keylinks - PROTYPES.CATEGORY=CONCUST.KIND
Keysource- dsCONCUST
When i run the programme (queries open in the oncreate of the
datamodule) the lookupcombo works ok.
When i click the button BTPROTYPES the projecttypes form is opened.
In this form when i try to scroll the grid i get a message that
'dataset cannot scroll'.The data in this table is located to the
category that the projects data was on when the projectstype form
was called. When i try to edit this record(the only one i can edit
since dataset cannot be scrolled) the projects table is also
set in edit mode and i undestand this from the colors since they
change when in different modes.The same happens if i try to add a
record in the PROTYPES table.
After i post the changes of the edits or insert then i can scroll the
grid.
The state of the projects file remains in edit mode.
The other thing that is happening is that the field of a projects
data in this case 'KIND' changes value as i scroll the PROTYPES
in the grid.Is this normal.
The code for saving the changes or inserts in the PROTYPES table
is
IF (IB_EDIT1.Text='') OR (LENGTH(IB_EDIT1.Text)<2) THEN
BEGIN
SHOWMESSAGE('WRONG CODE!!');
EXIT;
END;
DATA.qryPROCATEGORIES.Post;
DATA.tsCRAMS.Commit;
DATA.qryPROCATEGORIES.CLOSE;
DATA.qryPROCATEGORIES.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
Please tell what Iam doing wrong.I am new to programming c/s.
Thanks
Costas
My original message.
I am sorry for the misundestanding.I was not intending to do that at
all.Apologies.
My message is
I have a form with two TIB_QUERY objects,two IB_DATASOURCES and two
IB_TRANSACTIONS and also one connection.One query is for the PROJECT
table and the other for the PROJECTTYPE table.I also attach to each
two TIB_TRANSACTION .The field 'TYPE' in the PROJECT table is looked
from the PROJECTTYPE table.I have set up a TIB_LOOKUPCOMBO as
described in the GETTING STARTED GUIDE FOR IBOJECTS.Everything is
working fine as far as the TIB_LOOKUPCOMBO box is concerned but
i have noticed the following strange behaviour,i am sure i am doing
something wrong becase i am new to IBOBJECTS and client/server.
a.When I scroll the PROJECTTYPE TABLE using a TIB_GRID i have noticed
that sometimes a record is inserted in the PROJECT table and the
table gets into edit mode.
b. The value of the 'TYPE' field of the current record in the
PROJECT table changes value to correspond to the current record
of the PROJECTTYPES table current record and gets into edit mode
Please help me to undestand what Iam doing wrong.Also please tell me
if its a good policy to use a separate transaction TIB_TRANSACTION
for each table.
Again I apologise for the CAPS.
Thanks
COSTAS
My additional information
Thank you all for the answers.To undestand better my problem see
below
My project has 4 forms.The main form,the data module,the projects
detail form and the projects type form.The last two forms contain
each one IB_GRID and several IB_EDIT controls.
The data module contains the following.
1.TIB_QUERY(qrCONCUST) for the projects table(concust) with SQL as
below
'select * from concust'
2.TIB_QUERY (qrPROCATEGORIES)for the project types table(protypes)
with SQL as below
'select * from protypes'
3.Two TIB_DATASOURCES(dsCONCUST,qryPROCATEGORIES) connected to above
4.One TIB_CONNECTION(cnCRAMS) pointing to the database.
5.One TIB_TRANSACTION(tsCRAMS).
TIB_QUERIES ib_connections are set to cnCRAMS and ib_transactions
to tsCRAMS.
On the projects form i have buttons for editing the data and adding
data.
eg. the code for the ADD button is
DATA.qryCONCUST.Insert;
BTOK.Visible:=TRUE;
BTCANC.VISIBLE:=TRUE;
BTOK,BTCANC buttons are for commiting the changes of insert or
discarting them
The code for the BTOK button is
IF (IB_EDIT1.Text='') OR (LENGTH(IB_EDIT1.Text)<5) THEN
BEGIN
SHOWMESSAGE('WRONG CODE!!');
EXIT;
END;
DATA.qryCONCUST.Post;
DATA.tsCRAMS.Commit;
DATA.qryCONCUST.CLOSE;
DATA.qryCONCUST.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
The code for the BTCANC button is
DATA.qryCONCUST.Cancel;
DATA.tsCRAMS.Rollback;
DATA.qryCONCUST.CLOSE;
DATA.qryCONCUST.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
Similar controls and buttons exist for the projecttypes form
Everything works ok upto now.
When in the projects form i drop a TIB_LOOKUPCOMBO and set it up
my problems start.
Settings for the tib_lookupcombo
datasource : dsPROTYPES
custompopup :ib_grid2 (pointing to dsPROCATEGORIES)
Displayfield:Category (primary key in PROTYPES)
Settings for the qryPROCATEGORIES
keylinks - PROTYPES.CATEGORY=CONCUST.KIND
Keysource- dsCONCUST
When i run the programme (queries open in the oncreate of the
datamodule) the lookupcombo works ok.
When i click the button BTPROTYPES the projecttypes form is opened.
In this form when i try to scroll the grid i get a message that
'dataset cannot scroll'.The data in this table is located to the
category that the projects data was on when the projectstype form
was called. When i try to edit this record(the only one i can edit
since dataset cannot be scrolled) the projects table is also
set in edit mode and i undestand this from the colors since they
change when in different modes.The same happens if i try to add a
record in the PROTYPES table.
After i post the changes of the edits or insert then i can scroll the
grid.
The state of the projects file remains in edit mode.
The other thing that is happening is that the field of a projects
data in this case 'KIND' changes value as i scroll the PROTYPES
in the grid.Is this normal.
The code for saving the changes or inserts in the PROTYPES table
is
IF (IB_EDIT1.Text='') OR (LENGTH(IB_EDIT1.Text)<2) THEN
BEGIN
SHOWMESSAGE('WRONG CODE!!');
EXIT;
END;
DATA.qryPROCATEGORIES.Post;
DATA.tsCRAMS.Commit;
DATA.qryPROCATEGORIES.CLOSE;
DATA.qryPROCATEGORIES.OPEN;
BTOK.Visible:=FALSE;
BTCANC.VISIBLE:=FALSE;
Please tell what Iam doing wrong.I am new to programming c/s.
Thanks
Costas