Solved

Delphi

Posted on 2003-10-24
4
304 Views
Last Modified: 2012-05-04
Hi

I am new to Delphi and I have al ot of questions.  

I am writing a program that displays pager equipment information.  What happens is that there is a edit box which allows user to enter in the serial number or capcode of the pager (edEsn) and a search button in which the user clicks on to have a new window appear.  The new window (frmSrchPager) has a DBGrid with two columns.  One for Serial Number and one for Capcode.  When the user selects a serial number or capcode from the list and clicks ok, the original screen will populate with information about the pager selected.  The problem is that for every serial number, there is only one capcode but for every capcode, there could be many serial numbers.  When I search by capcode, the list would pull up a list of associating serial numbers.  However when I select one on the list, the first record on the list always populate the original screen ESNView.  If I select one in the middle of the list, the first one stills get chosen and displayed.

The code (brief)

In frmSrchPager:  The btOK procedure
Notice that Esn is String, edEsn is TEdit


          if frmEsnview.rbCapCode.Checked = True then
             begin
                frmEsnview.edEsn.Text := frmSrchpager.qrySrch.FieldByName('CAP_CODE').Text;

                Esn := frmSrchpager.qrySrch.FieldByName('SERIAL_NO').Text;

                frmEsnview.edEsn.SetFocus;
                Close;
             end
          else if frmEsnview.rbSerialNumber.Checked = True then
             begin
                frmEsnview.edEsn.Text := frmSrchpager.qrySrch.FieldByName('SERIAL_NO').Text;
                frmEsnview.edEsn.SetFocus;
                Close;
             end;
       end;

In the ESNView:  edActEnter Procedure (Display Screen)
var
   sTmpESN: string;
   bIsSearch: Boolean;
   Serial:  String;
begin
   bIsSearch := True;
   if (edActp.text = ' ') then
      begin { 1... Only the first time enter to populate the ESN query }
         if edEsn.text <> '' then {check esn validation}
            with FSerialNumVerifyQry do
               begin
                  if rbCapCode.Checked = True then
                         begin
                              Close;

                              Serial := frmSrchpager.qrySrch.FieldByName('SERIAL_NO').Text;  // HOW COME THIS DOESN'T WORK?  IT PRODUCES INACCESSIBLE VALUE

                              ParamByName('SERIAL_NO').AsString := Serial;
                              ParamByName('CAP_CODE').AsString := edEsn.Text;    // Changing Parameters for Pagers
                              Open;
                           end
                     else if rbSerialNumber.Checked = True then
                           begin
                              Close;
                              ParamByName('SERIAL_NO').AsString := edEsn.Text;
                              Open
                           end;
                     end
                 
 end; //with FSerialNumVerifyQry

         if not bIsSearch then
            begin
               edEsn.setFocus;
               Exit;
            end;

         if dsEquipInfo.Dataset <> nil then
         begin
         with (dsEquipInfo.DataSet as TQuery) do
                  if rbCapCode.Checked = True then
                     begin
                        if (active = true) then
                           close;
                        ParamByName('CAP_CODE').AsString := edEsn.text;
                        ParamByName('SERIAL_NO').AsString := frmSrchpager.Esn;  // ACCESS VIOLATION IS HERE AGAIN
                        Prepare;
                        Open;
                     end
                  else if rbSerialNumber.Checked = True then
                     begin
                       if (active = true) then
                          close;
                       ParamByName('SERIAL_NO').AsString := edEsn.Text;
                       Prepare;
                       Open;
                     end;
               end;
0
Comment
Question by:Magneto_Mystique
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 160 total points
ID: 9619391
Hard to read ;-)

>Serial := frmSrchpager.qrySrch.FieldByName('SERIAL_NO').Text;  
// HOW COME THIS DOESN'T WORK?  IT PRODUCES INACCESSIBLE VALUE

various possibilities
-your query qrySrch is closed
-instead of .Text use .AsString
-frmSrchpager is not created
-maybe more possibilities

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9619397
Hard to read again ;-)

>ParamByName('SERIAL_NO').AsString := frmSrchpager.Esn;  
// ACCESS VIOLATION IS HERE AGAIN

various possibilities
-frmSrchpager is not created
-What is Esn? Glabel Var? Object Attribute? Property? Object?
-maybe more possibilities

meikl ;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now