Board index » delphi » Field not found

Field not found


2004-07-02 12:08:52 AM
delphi39
I had a simple locate that worked. I then applied some code to
force the window to the front as elegantly created by John
Herbert in this NG. Applied as follows:
fmCoreStart.ForceForegroundWindowOK (fmArchiveData.Handle);
if not Temp.Locate('JobNo',
archiveDM.Jobs.FieldByName('JobNo').Value, []) then begin
Code for forceforegroundwindowOK is included below. It does
indeed bring the window to the fore but it also breaks the
locate, for some reason giving an error 'Jobs Field JobNo not
found' but commenting out the call to
fmCoreStart.ForceForegroundWindowOK renders it functional
again.
Debug tooltip shows that JobsJobNo does actually exist. fwiw the
table has no fields defined at designtime.
function TfmCoreStart.ForceForegroundWindowOK (h: HWND):
boolean;
var hCurWnd: THandle;
begin
hCurWnd := GetForegroundWindow;
AttachThreadInput(
GetWindowThreadProcessId(hCurWnd, nil),
GetCurrentThreadId, True);
Result := SetForegroundWindow(h);
AttachThreadInput(
GetWindowThreadProcessId(hCurWnd, nil),
GetCurrentThreadId, False);
end;
Pat Bell
 
 

Re:Field not found

"P.S.Bell" <XXXX@XXXXX.COM>wrote
Quote
I had a simple locate that worked. I then applied some
code to force the window to the front as elegantly created
by John [Herbster] in this NG.
Pat, Elegant, but dead on arrival? <g>
See tinyurl.com/ywu4c short for
www.google.com/groups
Quote
function TfmCoreStart.ForceForegroundWindowOK (h: HWND):
boolean;
Not that it should make much difference, but why did you make
this a method?
This "form" is not a TDataModule is it?
I do not immediately see the problem. Maybe someone else
can help. Regards, JohnH
 

Re:Field not found

Quote
Not that it should make much difference, but why did you make
this a method?
Why not? What should I have done? I have been putting general routines in my main form like this for years - have I just
exposed myself a a rank amateur? :-)
Quote

This "form" is not a TDataModule is it?
No the form I am bringing to the front is a TForm, but the table in the locate _is_ on a data module.
Quote

I do not immediately see the problem. Maybe someone else
can help. Regards, JohnH

Pat Bell
 

Re:Field not found

Quote
>Not that it should make much difference,
>but why did you make this a method?
Why not? What should I have done?
I can think of three reasons for putting this code in
a module with other utility code and one for doing
what you did:
(1) It requires copying and pasting of code for
each project that you use it in -- with the associated
chance for errors.
(2) It *implies* an untrue dependence of that code on
other things in the object. And that complicates the
view of the maintenance programmer.
(3) It does help to keep the form's code together.
(4) It makes it more difficult to reuse the code on
other projects.
Regards, JohnH
 

Re:Field not found

limelect writes:
Quote
Have an old appliction with bde sql. the sql is

Select * From GroupLink, GroupAppt
Where (SchedName = :SchedName)
And (GroupLink.ApptID = GroupAppt.ApptID)
And ((StartDate>= :D1) and (EndDate <= :D2))

The BDE software that work !!
with Query do
begin
ParamByName('D1').AsDate := BatchStartDate;
ParamByName(......
Manager1.RequestAppt(FieldByName('ApptID').AsString,.....

Moved to ADO
with Query do
begin
Parameters.ParamByName('D1').Value := BatchStartDate;
Parameters.ParamByName(......
Manager1.RequestAppt(FieldByName('ApptID').AsString,.... does not
work

geting Field 'ApptID' not found
What database are you using?
Are the column names case sensitive in the database you are using?
Which ADO component are you using?
Is the ParamCheck property of your dataset component true?
If you instantiate field objects at design time do you see ApptID?
--
Bill Todd (TeamB)
 

Re:Field not found

Well it is fixed but i do not understand
1. the db is mdb
2. i added GroupAppt.ApptID
Manager1.RequestAppt(FieldByName(' GroupAppt.ApptID').AsString
and it is ok but why? in the bde db you did not need it?
the component is TAdoQuery thankes
"Bill Todd" <XXXX@XXXXX.COM>writes
Quote
limelect writes:

>Have an old appliction with bde sql. the sql is
>
>Select * From GroupLink, GroupAppt
>Where (SchedName = :SchedName)
>And (GroupLink.ApptID = GroupAppt.ApptID)
>And ((StartDate>= :D1) and (EndDate <= :D2))
>
>The BDE software that work !!
>with Query do
>begin
>ParamByName('D1').AsDate := BatchStartDate;
>ParamByName(......
>Manager1.RequestAppt(FieldByName('ApptID').AsString,.....
>
>Moved to ADO
>with Query do
>begin
>Parameters.ParamByName('D1').Value := BatchStartDate;
>Parameters.ParamByName(......
>Manager1.RequestAppt(FieldByName('ApptID').AsString,.... does not
>work
>
>geting Field 'ApptID' not found

What database are you using?

Are the column names case sensitive in the database you are using?

Which ADO component are you using?

Is the ParamCheck property of your dataset component true?

If you instantiate field objects at design time do you see ApptID?

--
Bill Todd (TeamB)
 

Re:Field not found

limelect writes:
Quote
Well it is fixed but i do not understand
1. the db is mdb
I assume you mean some version of SQL Server between 7.0 and 2005.
Quote
2. i added GroupAppt.ApptID
Does ApptId occur in more than one table?
Is your SELECT a join on two tables that both contain ApptID?
Quote
Manager1.RequestAppt(FieldByName(' GroupAppt.ApptID').AsString
and it is ok but why? in the bde db you did not need it?
I have no idea. I have never encountered the problem you describe.
Quote
the component is TAdoQuery thankes
--
Bill Todd (TeamB)