Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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