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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLEASE HELP (1) 1

Status
Not open for further replies.

Kolelol

Programmer
Jul 17, 2001
5
ZA
Hi everybody !
Here is my problem. I have a form with a DBLookupComboBox and DBGrid. In the same program I have a DataModule with one table and one datasourse. All the properties of this components are properly (I think) set.
I have 2 simple procedures:

procedure SetOrderFilter(sRegionCode : String);
begin
With DataModule2.Table1 do
begin
Filter := 'RegionCode=' + sRegionCode;
Filtered := True;
end;
end;
procedure TForm1.DBLookupComboBox1CloseUp(Sender: TObject);
begin
if DBLookupComboBox1.Text <> '' then
begin
SetOrderFilter(DBLookupComboBox1.Text);
With DataModule2.Table1 do
Active := False;
end //if
end;
When I run the program and choose a field form the
DBLookupComboBox1 I get the message:
&quot;Table1: Field 'N' not found&quot; or Field 'S' etc...
My table has fields N, S, W, E etc.
What is wrong ???
Thanx in advance!!!
 
Does the table actually have fields called 'N', 'S', 'W' and 'E' or are these entries in the 'RegionCode' column. If we are looking at the latter ('RegionCode' contains N, S, W + E) then you need to modify your code in the Filter property. Please remember that this property is a String - the way in which you are currently setting this results in a Filter property of 'RegionCode = N' (for example) - this then filters for entries where the 'RegionCode' field value matches the 'N' field value. If this column ('N') does not exist then you will get the error &quot;Table1: Field 'N' not found&quot;.
If you are looking for filtering for entries where the 'RegionCode' field contains the 'N' character then you need to modify the setting of the 'Filter' property to be 'RegionCode = ''N''' (resulting in the Filter property = &quot;RegionCode = 'N'&quot; rather than &quot;RegionCode = N&quot;).
Hope this helps.
Steve
 
I figured it out. The field I was looking for is called RegionCode and I wanted to filter according to the entries - N, S, E etc. So you were right.
Thanks for your help.
 
I find that using the QuotedStr function to put constant stings into SQL and Filter expressions is nicer than doubling the apostrophes yourself - and the resulting code is much easier to follow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top