AbhiJeet
asked on
Dev express lookupcombo
Hi Experts,
I have an issue with Devexpress lookup combo.
In my form(testform) i have placed a lookupcombo. Set all the required properties like keyfieldname, listsource etc correctly. Listsource refers to a datasource placed in a datamodule which is linked to a query eg query1. In the Datamodule i have another query query2.
I have two menu items say menu1 and menu2 in my main form. If i click menu1 it opens testform and when menu2 is clicked it opens another form.
If i click menu1, it creates the datamodule and sets the parameter for query1 and opens the query to load the lookup combo.
Code written is not very complicated, just simple a snapshot is below:
with datamodule1 do
begin
query1.Params[0].AsString := 'Test';
query1.open;
query2. sql.text := 'Select name, desc from table1 where code = ' + FCode;
query2.Open;
luCombo.EditValue := query2.Fields[0].Value;
end; { Please ignore syntax error or type if any, because that is not the solution i am looking for}
Now i click on menu1, it opens my form and loads the combo correctly. I select a value from drop down and with out saving i navigate to menu2. While going to menu2 i am doing a query post as below:
With Datamodule1, query2 do
begin
Close;
query2. sql.text := 'Select name, desc from table1 where code = ' + FCode;
query2.Open;
if Fields[0]. Value <> luCombo.EditValue then
begin
Edit;
Fields[0].Value := luCombo.EditValue;
Post;
end;
Close;
end;
So it is supposed to post the value to query and when i come back to menu1 it should show me the value. But it doesn't do that way.
I click on menu1, it opens the form, i select a value from combo drop down, i then go to menu2 and then come back to menu1, the value is gone. Even the drop down list is not showing the records.
Any clue please?
I have an issue with Devexpress lookup combo.
In my form(testform) i have placed a lookupcombo. Set all the required properties like keyfieldname, listsource etc correctly. Listsource refers to a datasource placed in a datamodule which is linked to a query eg query1. In the Datamodule i have another query query2.
I have two menu items say menu1 and menu2 in my main form. If i click menu1 it opens testform and when menu2 is clicked it opens another form.
If i click menu1, it creates the datamodule and sets the parameter for query1 and opens the query to load the lookup combo.
Code written is not very complicated, just simple a snapshot is below:
with datamodule1 do
begin
query1.Params[0].AsString := 'Test';
query1.open;
query2. sql.text := 'Select name, desc from table1 where code = ' + FCode;
query2.Open;
luCombo.EditValue := query2.Fields[0].Value;
end; { Please ignore syntax error or type if any, because that is not the solution i am looking for}
Now i click on menu1, it opens my form and loads the combo correctly. I select a value from drop down and with out saving i navigate to menu2. While going to menu2 i am doing a query post as below:
With Datamodule1, query2 do
begin
Close;
query2. sql.text := 'Select name, desc from table1 where code = ' + FCode;
query2.Open;
if Fields[0]. Value <> luCombo.EditValue then
begin
Edit;
Fields[0].Value := luCombo.EditValue;
Post;
end;
Close;
end;
So it is supposed to post the value to query and when i come back to menu1 it should show me the value. But it doesn't do that way.
I click on menu1, it opens the form, i select a value from combo drop down, i then go to menu2 and then come back to menu1, the value is gone. Even the drop down list is not showing the records.
Any clue please?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Datamodule is not created automatically but whenever i navigate to menu1 it creates an instance of the datamodule runtime.