Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unruly Control
Message
De
02/05/1997 18:12:36
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00030343
Message ID:
00030704
Vues:
29
>>>>You're going to think I am crazy, but:
>>>>
>>>>I have a control on a form bound to a field in a table. The user selects a customer name and I put in the customer primary key into this invisible control's value property. When I save, all of the controls bound to this table save properly EXCEPT the CustPKey--I get nothing. I checked its Value just before saving (txtCustPKey.Value)--it's correct. I save--get nada in that one field only. I have checked every property and value I can think of. What would prevent a bound control from writing to the field in the table??? ARGH!!@!
>>>>
>>>>TIA.
>>>>
>>>>John
>>>
>>>check controlsource. also make sure you're not setting that value before you create the new record (if using buffering) -- otherwise it'll go to the previously active record
>>
>>David:
>>
>>This thing is driving me CRAZY. Here's the whole deal: I am trying to
>>create an invoice--simple enough, right? I generate an invoice #, the
>>user inputs (or selects) the date, salesperson, customer name. I have a
>>text control, txtCustPKey, that is marked .Visible = .F. As soon as the
>>user selects the customer name, I grab the Customer Primary Key:
>>THISFORM.txtCustPKey.Value = Customer.CustPKey. When I save, I get the
>>invoice #, date, and salesperson, but I get nothing for the CustPKey.
>>One line before before the TABLEUPDATE, I check the following:
>>
>>WAIT WINDOW "CustPKey:" + STR(THISFORM.txtCustPKey.Value) + " " +
>>THISFORM.txtCustPKey.ControlSource.
>>
>>I get the following result:
>>
>>CustPKey: 3 InvHead.CustPKey
>>
>>One line after the TABLEUPDATE, I ask the following:
>>
>>WAIT WINDOW STR(InvHead.InvNo) + STR(InvHead.CustPKey) +
>>STR(THISFORM.txtCustPKey.Value)
>>
>>I get the correct invoice #, a zero, and the correct customer #. I am
>>beginning to lose the big picture down here. I have deleted the control and added it back in. Nothing works. It's gonna drive me to drink. Any other thing for me to check???
>>
>>Thank you, as always, for kicking in.
>>
>>John
>
>try a replace immed. after the tableupdate? if that works, something isn't set right (bound, etc.)

Dave:
Your suggestion allowed me to find a work-around that works, but makes absolutely no sense. In my SAVE method in the form's base class, the code snippet below shows how I normally save data:

IF .NOT. TABLEUPDATE(1, .F., aBuffers[nN,1])
lRollBack = .T.
ENDIF

Adding the following makes it work:

IF UPPER(aBuffers[nN,1]) = "INVHEAD"
REPLACE InvHead.CustPKey WITH THIS.txtCustPKey.Value
TABLEUPDATE()
ENDIF

If I do not do the hard-coded REPLACE, I get a zero for InvHead.CustPKey. All other saves for all other tables in every other situation works with the generic SAVE routine except for this one. I know the VALUE is set correctly or my work-around wouldn't work. I have un-bound and re-bound the text box. I have deleted and re-created the text box. Nothing works except the above.

I am not at all happy with the work-around: I hate having code like this in a method in my base data entry form class. (I can't put the code in the sub-classed version (the invoice form itself) for reasons I will bore you with only if you insist.) Plus I hate the overhead involved with two TABLEUPDATEs. But at least it allows me to continue to work on the invoice.

If you have *any* idea where to look, I would be, as always, most grateful.

John
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform