?
Solved

Delphi

Posted on 2003-10-24
4
Medium Priority
?
309 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 640 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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