Solved

Delphi

Posted on 2003-10-24
4
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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