Solved

Delphi

Posted on 2003-10-24
4
303 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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

13 Experts available now in Live!

Get 1:1 Help Now