this is how i save my record but where would i put it, i tried right under the
if llok
thisform.pageframe1.page2.btninvoice.enabled = .t.
thisform.release()
but it doesnt work?
** enclose this in a transaction later
LOCAL llok
llok = .f.
TRY
BEGIN TRANSACTION && start the transaction
IF TABLEUPDATE(0, .T., "appointment")AND ;
TABLEUPDATE(1, .T., "procedures")AND ;
TABLEUPDATE(0, .T., "billing")
END TRANSACTION && save changes as both were updated successfully
llok = .t. && ok to exit form
ELSE
** oops, we had an error of some kind, rollback the transaction
ROLLBACK
ENDIF
CATCH TO ex
DO WHILE TXNLEVEL() > 0
ROLLBACK
ENDDO
** display
MESSAGEBOX("Unexpected error as occurred: "+ex.message, 48, this.Caption)
ENDTRY
well, because i am dealing with a appointments, If the appointment
is created the invoice can be created
if it is not created the invoice cannot be created
Sure go ahead and Enable the Button, but Releasing the Form negates anything you do to the objects on the Form itself.
So your Enable is immediately negated when the Form obliterates the Button object itself with the Release.
Based on the level of 'understanding' that code suggests I am guessing that your whole Form operation might be in question and might need re-designing and developing to work in a totally different manner.
I dont know about re-desinging the entire form, i do have an alternate solution. Once the record is saved, becuase the data is then viewed in my appointment list, i can just create a right click menu with a "Generate Invoice" selection.
Thanks Guys since IT DOES NOT MAKE SENSE i will remove the button.
I think you still didn't get what our understanding is. So perhaps a question first:
Are we dealing with one or two forms?
Thisform is thisform. As the code you use to enable the button and to close the form is in the same method, it is adressing the same. So you enable a button that is on a form you release in the next moment. If this is meant to enable a button on another form, you would need to enable the button in that form.
In the simplest way you make the form you release modal, then calling that form from the first form with the button would keep it in a wait state and after you release the form we talk about here, you return to the line after the DO FORM and then you can enable the button.
If you have such interdependencies, you may also pass the form reference thisform from the calling form to the called form DO FORM ... WITH THISFORM. This arrives as a parameter in the init of the called form and you can save that parameter into a form property to make use of it when you successfully save.
Or you DO FORM ... TO Variable, which works with modal forms again, and then you can return a value in the Unload() event of the called form, eg you can return if the save succeeded or not.
You may also determine the success of the save by seeking the appointment needed for the invoice. That makes it easier in terms of dependencies of the forms themselves. The appointment doesn't need to report it's success to the invoice form, the invoice form just looks up, if the record it needs to relate the invoice to exists or not.
Your "save record" code doesn't make much sense either. You are calling TABLEUPDATE(), which means that your tables are buffered. That's good. But if the updates fail, you should be reverting the buffers (by calling TABLEREVERT()). Using BEING TRANSACTION is fine, but it's not the whole story.
Also, you only have one level of transaction processing in this code, but you are calling ROLLBACK for all current transaction levels (that's what DO WHILE TXNLEVEL() > 0 is doing). At best, that's a waste of time. At worst, you will be rolling back other transactions, unrelated to the code you have shown.
You have asked what should be a simple question, and in return we have given you a barrage of criticism. I appreciate that's not what you want. But your code and your question do show a basic lack of understanding of what's going on in your application.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
As Olaf, Dan, and Myself have said - it makes NO SENSE WHATSOEVER and Your "save record" code doesn't make much sense either and as Mike has said so 'to the point' - your code and your question do show a basic lack of understanding of what's going on in your application.
We really don't say those things with the intent of being rude or insulting, but with the hope that if enough people see GENERAL PROBLEMS and comment on it to you, you might read our comments and understand that we think you might want to re-think how you are approaching things on a larger scale and perhaps re-design the whole thing.
Perhaps it is just that you are trying to make the whole thing much more complicated than it need be.
and I do have some visual fox pro books, so yes I am learning. I could tell you I probably did take it rather offensive when dan said "MAKES NO SENSE AT ALL"
in capital letters above all.
But I guess your right JRB-Bldr, the design of my prg is my biggest problem only because im doing it from the top of my head.
But thank you all for your input and suggestion.
I honestly wish i had a guy like Olaf to teach me, he comes out as a very good speaker.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.