Board index » delphi » More help needed with linking two forms

More help needed with linking two forms

Hi, I'm almost there, but...

I am trying to link two forms - The main form  has an ID field and the
requirement has a ReqID field.  I have a Button on main form for see
requirements.  When the user clicks on the "See Requirements Button", I
want the Requirements form to appear, and the user should be able to scroll
through the different requirements one at a time using the DBNavigator
Button.

I have the following code:

procedure TRequirements.FormCreate(Sender: TObject);

var
  i, code : integer;

begin
  Val(MyBadges.EditID.Text, I, Code);
  Query1.ParamByName('BadgeID').AsInteger := I;
  Query1.Open;
end;

When I click on the See Requirements button, it lets me browse through the
requirements database, however I can only see the requirements for badge
#1.  Even if I go to badge 2 or higher, it only brings up requirements with
ReqID = 1.  Can someone give me a hand..... is this being placed in the
wrong area or something???

Thanks in advance....  

Kevin Coleman
--

Kevin Coleman
http://members.aol.com/kevinc1081

 

Re:More help needed with linking two forms


Hi Mark, thanks for your info - I tried the strtoint instead of Val and I
got the same result.

I have one paramater named badgeid and it is of data type integer.  There
is no value and the null value box is not checked.

My SQL code says:

Select
  jrbadreq."ReqID",
  jrbadreq."ReqNumber",
  jrbadreq."Requirement",
  jrbadreq."ReqDate"
From "c:\delphi\jrbadreq.db"
Where reqid = :badgeid

It still for some reason is still selecting all records with the reqid of 1
even if it should be 2 or 3.  I stepped through the execution of the
program and it seems like it's choosing the number at compile time instead
of when the button is pressed.  Maybe the params code shouldn't be in the
TRequirements.FormCreate area?!?!?

Thanks for your help.... Kevin
--

Kevin Coleman
http://members.aol.com/kevinc1081

Re:More help needed with linking two forms


Quote
Kevin Coleman wrote:

> Hi, I'm almost there, but...

> I am trying to link two forms - The main form  has an ID field and the
> requirement has a ReqID field.  I have a Button on main form for see
> requirements.  When the user clicks on the "See Requirements Button", I
> want the Requirements form to appear, and the user should be able to scroll
> through the different requirements one at a time using the DBNavigator
> Button.

> I have the following code:

> procedure TRequirements.FormCreate(Sender: TObject);

> var
>   i, code : integer;

> begin
>   Val(MyBadges.EditID.Text, I, Code);
>   Query1.ParamByName('BadgeID').AsInteger := I;
>   Query1.Open;
> end;

> When I click on the See Requirements button, it lets me browse through the
> requirements database, however I can only see the requirements for badge
> #1.  Even if I go to badge 2 or higher, it only brings up requirements with
> ReqID = 1.  Can someone give me a hand..... is this being placed in the
> wrong area or something???

Have you checked that the text in the edit box is being converted
correctly?  Why not try StrToInt?  If this is not the problem, it may be
with your SQL...can we have some more info?

--
Mark.

Re:More help needed with linking two forms


Thanks for the help (rec'd through email). Actually, I managed to get it to
work this morning from a hint.  In the OnCreate event on the requirement
form, it had FormCreate.  I got rid of that and changed the OnActive to
FormCreate and the OnClose to FormClose (closed the table).  That worked!!!
Thanks for everything!!!  (I'm getting there) Kevin
--

Kevin Coleman
http://members.aol.com/kevinc1081

Other Threads