| View previous topic :: View next topic |
| Author |
Message |
Kimberly Mills Guest
|
Posted: Wed Aug 06, 2003 8:29 pm Post subject: DBEdit - Ability to restrict a character? |
|
|
Hi,
I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?
The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).
Any help is always greatly appreciated.
Kim
procedure TSetupExtOrgCourseMappingForm.DisplayExtOrgCredits;
begin
With ExtOrgCreditsQuery do begin
If Active then Close;
With SQL do begin
Clear;
Add ('Select credit_hrs ');
Add ('From ext_org_course_catalog ' );
Add ('Where master_Catalog_id = ''' + edtMasterCatalogID.Text + '''
and ');
Add ('ext_org_dept_cd = ''' + cbExtOrgDept.Text + ''' and ');
Add ('ext_org_course_cd = ''' + cbExtOrgCourse.Text + ''' and ');
Add ('ext_org_course_title = ''' + cbTitle.Text + ''' and ');
Add ('eff_status = ''A'' ');
Add ('Order by effdt desc ');
end;
open;
edtExtOrgCredits.text := FieldByName('credit_hrs').AsString;
close;
end;
end;
|
|
| Back to top |
|
 |
Ryan Mills Guest
|
Posted: Wed Aug 06, 2003 10:37 pm Post subject: Re: DBEdit - Ability to restrict a character? |
|
|
| Quote: | I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?
The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).
Any help is always greatly appreciated.
|
Try using the function ansiquotestr. It would look something like this....
Add ('Where master_Catalog_id = ' + AnsiQuotesStr(edtMasterCatalogID.Text, ''') + ' and ');
Ryan
|
|
| Back to top |
|
 |
Pomme-granite Guest
|
Posted: Thu Aug 07, 2003 11:36 am Post subject: Re: DBEdit - Ability to restrict a character? |
|
|
If you created the query statically at designtime (rather than build
in your code) and added persistent fields, then it is easy :
ExtOrgCreditsQueryYOURFIELD.ValidChars :=
ExtOrgCreditsQueryYOURFIELD.ValidChars - [''''];
Paul Scott
On Wed, 6 Aug 2003 15:29:24 -0500, "Kimberly Mills"
<kimmills (AT) indiana (DOT) edu> wrote:
| Quote: | Hi,
I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?
The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).
Any help is always greatly appreciated.
Kim
procedure TSetupExtOrgCourseMappingForm.DisplayExtOrgCredits;
begin
With ExtOrgCreditsQuery do begin
If Active then Close;
With SQL do begin
Clear;
Add ('Select credit_hrs ');
Add ('From ext_org_course_catalog ' );
Add ('Where master_Catalog_id = ''' + edtMasterCatalogID.Text + '''
and ');
Add ('ext_org_dept_cd = ''' + cbExtOrgDept.Text + ''' and ');
Add ('ext_org_course_cd = ''' + cbExtOrgCourse.Text + ''' and ');
Add ('ext_org_course_title = ''' + cbTitle.Text + ''' and ');
Add ('eff_status = ''A'' ');
Add ('Order by effdt desc ');
end;
open;
edtExtOrgCredits.text := FieldByName('credit_hrs').AsString;
close;
end;
end;
|
|
|
| Back to top |
|
 |
Kimberly Mills Guest
|
Posted: Fri Aug 08, 2003 2:46 pm Post subject: Re: DBEdit - Ability to restrict a character? |
|
|
Hi Ryan,
Your awesome!! This worked like a charm!! Thanks so much for your help!
Kim Mills
<Ryan Mills> wrote
| Quote: | I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this
possible?
The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in
the
following code).
Any help is always greatly appreciated.
Try using the function ansiquotestr. It would look something like
this....
Add ('Where master_Catalog_id = ' + AnsiQuotesStr(edtMasterCatalogID.Text,
''') + ' and ');
Ryan
|
|
|
| Back to top |
|
 |
|