| View previous topic :: View next topic |
| Author |
Message |
MrT Guest
|
Posted: Sat May 20, 2006 12:14 am Post subject: Visibility |
|
|
Hi:
I have a DBComboBox on a modal form and want to access its KeyValue
int sYear = AssocMemberDues->DataYearCB->KeyValue;
in a block on a DM associated with the form.
This results in AV
int sYear = AssocMemberDues->DataYearCB->KeyValue;
^
NULL
All proper references are included. Why wouldn't this be visible??
Thanks.
Best regards |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat May 20, 2006 12:14 am Post subject: Re: Visibility |
|
|
"MrT" <contact@heat-mi.org> wrote in message
news:446e50d8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | This results in AV
int sYear = AssocMemberDues->DataYearCB->KeyValue;
^
NULL
|
Where exactly is the 'AssocMemberDues' variable declared? How exactly are
are instantiating the modal form instance? Where exactly are you calling
the above line of code from? You are either trying to access the DBComboBox
before the modal form has actually been created, or else you did not assign
the modal form's pointer to the 'AssocMemberDues' variable that you are
trying to access the form's contents through.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat May 20, 2006 2:14 am Post subject: Re: Visibility |
|
|
"MrT" <contact@heat-mi.org> wrote in message
news:446e6de9 (AT) newsgroups (DOT) borland.com...
| Quote: | TAssocMemberDues *AssocMemberDues;
|
That is declared as a global variable in TAssocMemberDues's .cpp file.
Presumably there is an associated 'extern' statement in TAssocMemberDues's
..h header file as well.
| Quote: | TAssocMemberDues *AssocMemberDues = new TAssocMemberDues(Application);
|
You are assigning the new form instance to a variable that is local to
ChildPaymentBtnClick() only. The global variable is never assigned any
value, and as such the DM cannot access the modal form.
You need to remove the first class name from the above line in order to
assign the global variable, ie:
void __fastcall TAssocChildForm::ChildPaymentBtnClick(TObject *Sender)
{
AssocMemberDues = new TAssocMemberDues(Application); // <-- no local
variable
AssocMemberDues->ShowModal();
delete AssocMemberDues;
}
Gambit |
|
| Back to top |
|
 |
MrT Guest
|
Posted: Sat May 20, 2006 2:14 am Post subject: Re: Visibility |
|
|
Further:
From Watch @ break.
AssocMemberDues: NULL
AssocChildForm: :02357600
MainForm: :01258BCC
AssocDuesForm is on top of the AssocChildForm which is on top of the
MainForm when this break occurs.
This is break at <---- below
if (SourceField == 1) <---------------------------
{
TDateTime pDate;
int sYear = AssocMemberDues->DataYearCB->KeyValue; <----AV
pDate = StrToDate(Sender->Text);
unsigned short pYear, pMonth, pDay;
DecodeDate(pDate, pYear, pMonth, pDay);
if (pYear != sYear)
{
MessageBeep(-1); MessageBeep(-1);MessageBeep(-1);
if (Application->MessageBox("The date input is not for the
same year as the record being updated. "
"You cannot enter a date paid
for a different year "
"than the year currently being
serviced. "
"If you do not understand this
message, you are a nutjob. ",
"Verify date Range",
MB_OK | MB_ICONEXCLAMATION |
MB_DEFBUTTON1 | MB_TASKMODAL) ==
IDOK)
{
Sender->Value = Text;
Sender->FocusControl();
}
}
}
MrT wrote:
| Quote: | Remy Lebeau (TeamB) wrote:
"MrT" <contact@heat-mi.org> wrote in message
news:446e50d8$1 (AT) newsgroups (DOT) borland.com...
This results in AV
int sYear = AssocMemberDues->DataYearCB->KeyValue;
^
NULL
Where exactly is the 'AssocMemberDues' variable declared?
TAssocMemberDues *AssocMemberDues;
//---------------------------------------------------------------------------
__fastcall TAssocMemberDues::TAssocMemberDues(TComponent* Owner)
: TForm(Owner)
{
if (!AssocDM->IBAssocDuesTransaction->Active)
AssocDM->IBAssocDuesTransaction->StartTransaction();
SetPaymentYear(StrToInt(MainForm->DataYearCB->KeyValue));
}
How exactly are
are instantiating the modal form instance?
//---------------------------------------------------------------------------
void __fastcall TAssocChildForm::ChildPaymentBtnClick(TObject *Sender)
{
TAssocMemberDues *AssocMemberDues = new TAssocMemberDues(Application);
AssocMemberDues->ShowModal();
delete AssocMemberDues;
}
Where exactly are you calling
the above line of code from?
From a DM that is instantiated when the app starts. The DM contains
the datasets which the assocmembersdues form/controls are using as well
as other code.
The line of code is in a field verification routine called from a date
change in a DBedit. The underlying TField object calls the routine as do
many others.
So sequence is DM instantiated then later AssocChildForm called from
MainForm and from that AssocChildForm the call to the AssocMemberDues.
You are either trying to access the DBComboBox
before the modal form has actually been created, or else you did not
assign
the modal form's pointer to the 'AssocMemberDues' variable that you are
trying to access the form's contents through.
Gambit
|
|
|
| Back to top |
|
 |
MrT Guest
|
Posted: Sat May 20, 2006 2:14 am Post subject: Re: Visibility |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | "MrT" <contact@heat-mi.org> wrote in message
news:446e50d8$1 (AT) newsgroups (DOT) borland.com...
This results in AV
int sYear = AssocMemberDues->DataYearCB->KeyValue;
^
NULL
Where exactly is the 'AssocMemberDues' variable declared?
|
TAssocMemberDues *AssocMemberDues;
//---------------------------------------------------------------------------
__fastcall TAssocMemberDues::TAssocMemberDues(TComponent* Owner)
: TForm(Owner)
{
if (!AssocDM->IBAssocDuesTransaction->Active)
AssocDM->IBAssocDuesTransaction->StartTransaction();
SetPaymentYear(StrToInt(MainForm->DataYearCB->KeyValue));
}
How exactly are
| Quote: | are instantiating the modal form instance?
|
//---------------------------------------------------------------------------
void __fastcall TAssocChildForm::ChildPaymentBtnClick(TObject *Sender)
{
TAssocMemberDues *AssocMemberDues = new TAssocMemberDues(Application);
AssocMemberDues->ShowModal();
delete AssocMemberDues;
}
Where exactly are you calling
| Quote: | the above line of code from?
|
From a DM that is instantiated when the app starts. The DM contains
the datasets which the assocmembersdues form/controls are using as well
as other code.
The line of code is in a field verification routine called from a date
change in a DBedit. The underlying TField object calls the routine as do
many others.
So sequence is DM instantiated then later AssocChildForm called from
MainForm and from that AssocChildForm the call to the AssocMemberDues.
You are either trying to access the DBComboBox
| Quote: | before the modal form has actually been created, or else you did not assign
the modal form's pointer to the 'AssocMemberDues' variable that you are
trying to access the form's contents through.
Gambit
|
|
|
| Back to top |
|
 |
MrT Guest
|
Posted: Sat May 20, 2006 12:14 pm Post subject: Re: Visibility |
|
|
Thanks. That solved it. Good grief. Now I have to gpo back and look
elsewhere.
That was normal design mode for me. All over but never a problem.
Remy Lebeau (TeamB) wrote:
| Quote: | "MrT" <contact@heat-mi.org> wrote in message
news:446e6de9 (AT) newsgroups (DOT) borland.com...
TAssocMemberDues *AssocMemberDues;
That is declared as a global variable in TAssocMemberDues's .cpp file.
Presumably there is an associated 'extern' statement in TAssocMemberDues's
.h header file as well.
TAssocMemberDues *AssocMemberDues = new TAssocMemberDues(Application);
You are assigning the new form instance to a variable that is local to
ChildPaymentBtnClick() only. The global variable is never assigned any
value, and as such the DM cannot access the modal form.
You need to remove the first class name from the above line in order to
assign the global variable, ie:
void __fastcall TAssocChildForm::ChildPaymentBtnClick(TObject *Sender)
{
AssocMemberDues = new TAssocMemberDues(Application); // <-- no local
variable
AssocMemberDues->ShowModal();
delete AssocMemberDues;
}
Gambit
|
|
|
| Back to top |
|
 |
|