Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Once a Record is Saved btn.enabled

Status
Not open for further replies.

mikeisvfp

Programmer
Mar 5, 2011
91
CA
Hello Experts

How would I tell vfp that once the record is saved enable this.btn?
If i am starting a new record it should be disabled..

Please help

Thanks Mike
 
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

IF llok
thisform.Release()
ENDIF
 
Since you're releasing the form it makes NO SENSE WHATSOEVER to enable a button on the form you're releasing.
 
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

What do you suggest at this point?
 
I agree with Dan above, the following code makes absolutely no sense.

Code:
thisform.pageframe1.page2.btninvoice.enabled = .t.
thisform.release

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.

Good Luck,
JRB-Bldr
 
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.

 
Oy.

I'm curious about one thing: when do you expect the user to be able to click the button that doesn't exist any more?

I'm curious about this thought process.
 
Mike,

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.

Bye, Olaf.
 
Mike,

Just to add to the above comments:

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)

Visual FoxPro articles, tips, training, consultancy
 
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.

Good Luck,
JRB-Bldr

 
Hey Guys

Im actually pretty new at visual fox pro, and I have been looking a videos form 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.

Thanks Guys
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top