Página 1 de 1

Setting Data Control Edits Initial value when Appending records ....

Publicado: Jue Mar 03, 2011 10:27 am
por ChrisGillard
Hi,
I am trying to set initial values into some Data Control Edits during
Appending of new records.
Below is the only code that I can get to work but seems complicated.
METHOD NlTranDsAddNew( oSender ) CLASS TForm1
::oNlTranDs:GoBottom() // Go to bottom
of file to pick up some field values
// This is a complicated way of getting default values into the Data
Aware Controls for editing
::oNlTranDs:TRANNO( dsOBJECT ):DefValue := ::oNlTranDs:TRANNO + 1
::oNlTranDs:FY( dsOBJECT ):DefValue := ::oNlTranDs:FY
// Data Controls will show these Values on the screen
RETURN Nil
I really want to put the values into the DataSet record buffer and then just
oDs:UpdateControls() to show the values, but cant get it to work.
Any thoughts on how to set & display these initial values would be
appreciated.
Chris

Setting Data Control Edits Initial value when Appending records ....

Publicado: Jue Mar 03, 2011 10:59 am
por ignacio
Chris,
You can set the values directly to the dataset, but after the call to the
AddNew() event. For example:
Using a temporal var:
WITH OBJECT oDataset
:GoBottom()
VarTranNo := :TranNo + 1
:AddNew()
:TranNo := VarTranNo
END WITH
(There should be no need to call oDs:UpdateControls)
Without using a temporal var :
WITH OBJECT oDataset
:AddNew()
:SaveState( .t. )
:GoBottom()
:TranNo := :TranNo( dsVALUE ) + 1
:RestoreState( .t. )
END WITH
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
http://www.xailer.com/forum
http://www.xailer.com/dokuwiki
"Chris Gillard" escribió en el mensaje de
noticias:4d6f5f20$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
Hi,
I am trying to set initial values into some Data Control Edits during
Appending of new records.
Below is the only code that I can get to work but seems complicated.
METHOD NlTranDsAddNew( oSender ) CLASS TForm1
::oNlTranDs:GoBottom() // Go to bottom
of file to pick up some field values
// This is a complicated way of getting default values into the Data
Aware Controls for editing
::oNlTranDs:TRANNO( dsOBJECT ):DefValue := ::oNlTranDs:TRANNO + 1
::oNlTranDs:FY( dsOBJECT ):DefValue := ::oNlTranDs:FY
// Data Controls will show these Values on the screen
RETURN Nil
I really want to put the values into the DataSet record buffer and then just
oDs:UpdateControls() to show the values, but cant get it to work.
Any thoughts on how to set & display these initial values would be
appreciated.
Chris

Setting Data Control Edits Initial value when Appending records ....

Publicado: Jue Mar 03, 2011 11:11 am
por ChrisGillard
Ignacio,
Thanks for that, its much more how I hoped it could bwe done.
My only problem now is to do it when using the Dbnavigator control and its
ADD button.
I need to find somewhere to put your code, you may have a suggestion to help
please?
Chris
"Ignacio Ortiz de Zúñiga" <NoNameToAvoidSpam@xailer.com> wrote in message
news:[email=4d6f669e@svctag-j7w3v3j....]4d6f669e@svctag-j7w3v3j....[/email]
> Chris,
>
> You can set the values directly to the dataset, but after the call to the
> AddNew() event. For example:
>
> Using a temporal var:
>
> WITH OBJECT oDataset
> :GoBottom()
> VarTranNo := :TranNo + 1
> :AddNew()
> :TranNo := VarTranNo
> END WITH
>
> (There should be no need to call oDs:UpdateControls)
>
> Without using a temporal var :
>
> WITH OBJECT oDataset
> :AddNew()
> :SaveState( .t. )
> :GoBottom()
> :TranNo := :TranNo( dsVALUE ) + 1
> :RestoreState( .t. )
> END WITH
>
> Regards,
>
>
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer / Xailer team]
> http://www.xailer.com
> http://www.xailer.info
> http://www.xailer.com/forum
> http://www.xailer.com/dokuwiki
> "Chris Gillard" escribió en el mensaje de
> noticias:4d6f5f20$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
>
> Hi,
>
> I am trying to set initial values into some Data Control Edits during
> Appending of new records.
>
> Below is the only code that I can get to work but seems complicated.
>
> METHOD NlTranDsAddNew( oSender ) CLASS TForm1
> ::oNlTranDs:GoBottom() // Go to bottom
> of file to pick up some field values
> // This is a complicated way of getting default values into the Data
> Aware Controls for editing
> ::oNlTranDs:TRANNO( dsOBJECT ):DefValue := ::oNlTranDs:TRANNO + 1
> ::oNlTranDs:FY( dsOBJECT ):DefValue := ::oNlTranDs:FY
> // Data Controls will show these Values on the screen
> RETURN Nil
>
> I really want to put the values into the DataSet record buffer and then
> just
> oDs:UpdateControls() to show the values, but cant get it to work.
>
> Any thoughts on how to set & display these initial values would be
> appreciated.
>
> Chris
>

Setting Data Control Edits Initial value when Appending records ....

Publicado: Jue Mar 03, 2011 1:38 pm
por ignacio
Chris,
Then you should perform the complete operation. Something like this:
METHOD DBNavigatorClickInsert( oSender ) CLASS TMyForm
::oDataset:AddNew()
/*your code goes here*/
::oDbNavigator:UnLock()
RETURN .F.
METHOD DBNavigatorClickEdit( oSender ) CLASS TMyForm
::oDataset:Edit()
/*your code goes here*/
::oDbNavigator:UnLock()
RETURN .F.
Remember to call oDbNavigator:Lock() after the oDataset:Update()
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
http://www.xailer.com/forum
http://www.xailer.com/dokuwiki
"Chris Gillard" escribió en el mensaje de
noticias:[email=4d6f694c@svctag-j7w3v3j....]4d6f694c@svctag-j7w3v3j....[/email]
Ignacio,
Thanks for that, its much more how I hoped it could bwe done.
My only problem now is to do it when using the Dbnavigator control and its
ADD button.
I need to find somewhere to put your code, you may have a suggestion to help
please?
Chris
"Ignacio Ortiz de Zúñiga" <NoNameToAvoidSpam@xailer.com> wrote in message
news:[email=4d6f669e@svctag-j7w3v3j....]4d6f669e@svctag-j7w3v3j....[/email]
> Chris,
>
> You can set the values directly to the dataset, but after the call to the
> AddNew() event. For example:
>
> Using a temporal var:
>
> WITH OBJECT oDataset
> :GoBottom()
> VarTranNo := :TranNo + 1
> :AddNew()
> :TranNo := VarTranNo
> END WITH
>
> (There should be no need to call oDs:UpdateControls)
>
> Without using a temporal var :
>
> WITH OBJECT oDataset
> :AddNew()
> :SaveState( .t. )
> :GoBottom()
> :TranNo := :TranNo( dsVALUE ) + 1
> :RestoreState( .t. )
> END WITH
>
> Regards,
>
>
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer / Xailer team]
> http://www.xailer.com
> http://www.xailer.info
> http://www.xailer.com/forum
> http://www.xailer.com/dokuwiki
> "Chris Gillard" escribió en el mensaje de
> noticias:4d6f5f20$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
>
> Hi,
>
> I am trying to set initial values into some Data Control Edits during
> Appending of new records.
>
> Below is the only code that I can get to work but seems complicated.
>
> METHOD NlTranDsAddNew( oSender ) CLASS TForm1
> ::oNlTranDs:GoBottom() // Go to bottom
> of file to pick up some field values
> // This is a complicated way of getting default values into the Data
> Aware Controls for editing
> ::oNlTranDs:TRANNO( dsOBJECT ):DefValue := ::oNlTranDs:TRANNO + 1
> ::oNlTranDs:FY( dsOBJECT ):DefValue := ::oNlTranDs:FY
> // Data Controls will show these Values on the screen
> RETURN Nil
>
> I really want to put the values into the DataSet record buffer and then
> just
> oDs:UpdateControls() to show the values, but cant get it to work.
>
> Any thoughts on how to set & display these initial values would be
> appreciated.
>
> Chris
>

Setting Data Control Edits Initial value when Appending records ....

Publicado: Jue Mar 03, 2011 3:33 pm
por ChrisGillard
Ignacio,
I now understand what to do by replacing the standard DBNavigator
ClickInsert code with my own code to do the whole job.
Xailer is truly flexible.
Thanks for your time to help with this.
Regards
Chris
"Ignacio Ortiz de Zúñiga" <NoNameToAvoidSpam@xailer.com> wrote in message
news:4d6f8bd4$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris,
>
> Then you should perform the complete operation. Something like this:
>
> METHOD DBNavigatorClickInsert( oSender ) CLASS TMyForm
>
> ::oDataset:AddNew()
> /*your code goes here*/
> ::oDbNavigator:UnLock()
>
> RETURN .F.
>
> METHOD DBNavigatorClickEdit( oSender ) CLASS TMyForm
>
> ::oDataset:Edit()
> /*your code goes here*/
> ::oDbNavigator:UnLock()
>
> RETURN .F.
>
> Remember to call oDbNavigator:Lock() after the oDataset:Update()
>
> Regards,
>
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer / Xailer team]
> http://www.xailer.com
> http://www.xailer.info
> http://www.xailer.com/forum
> http://www.xailer.com/dokuwiki
> "Chris Gillard" escribió en el mensaje de
> noticias:[email=4d6f694c@svctag-j7w3v3j....]4d6f694c@svctag-j7w3v3j....[/email]
>
> Ignacio,
>
> Thanks for that, its much more how I hoped it could bwe done.
>
> My only problem now is to do it when using the Dbnavigator control and its
> ADD button.
>
> I need to find somewhere to put your code, you may have a suggestion to
> help
> please?
>
> Chris
>
> "Ignacio Ortiz de Zúñiga" <NoNameToAvoidSpam@xailer.com> wrote in message
> news:[email=4d6f669e@svctag-j7w3v3j....]4d6f669e@svctag-j7w3v3j....[/email]
>> Chris,
>>
>> You can set the values directly to the dataset, but after the call to the
>> AddNew() event. For example:
>>
>> Using a temporal var:
>>
>> WITH OBJECT oDataset
>> :GoBottom()
>> VarTranNo := :TranNo + 1
>> :AddNew()
>> :TranNo := VarTranNo
>> END WITH
>>
>> (There should be no need to call oDs:UpdateControls)
>>
>> Without using a temporal var :
>>
>> WITH OBJECT oDataset
>> :AddNew()
>> :SaveState( .t. )
>> :GoBottom()
>> :TranNo := :TranNo( dsVALUE ) + 1
>> :RestoreState( .t. )
>> END WITH
>>
>> Regards,
>>
>>
>> Ignacio Ortiz de Zúñiga
>> [Equipo de Xailer / Xailer team]
>> http://www.xailer.com
>> http://www.xailer.info
>> http://www.xailer.com/forum
>> http://www.xailer.com/dokuwiki
>> "Chris Gillard" escribió en el mensaje de
>> noticias:4d6f5f20$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
>>
>> Hi,
>>
>> I am trying to set initial values into some Data Control Edits during
>> Appending of new records.
>>
>> Below is the only code that I can get to work but seems complicated.
>>
>> METHOD NlTranDsAddNew( oSender ) CLASS TForm1
>> ::oNlTranDs:GoBottom() // Go to
>> bottom
>> of file to pick up some field values
>> // This is a complicated way of getting default values into the Data
>> Aware Controls for editing
>> ::oNlTranDs:TRANNO( dsOBJECT ):DefValue := ::oNlTranDs:TRANNO + 1
>> ::oNlTranDs:FY( dsOBJECT ):DefValue := ::oNlTranDs:FY
>> // Data Controls will show these Values on the screen
>> RETURN Nil
>>
>> I really want to put the values into the DataSet record buffer and then
>> just
>> oDs:UpdateControls() to show the values, but cant get it to work.
>>
>> Any thoughts on how to set & display these initial values would be
>> appreciated.
>>
>> Chris
>>
>