Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Stewart Chew
  Where is Stewart Chew?
 
 Malaysia
 Stewart Chew
 Tags
Subject: RE: Insert & Update records
Thread ID: 145129 Message ID: 145852 # Views: 20 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Wednesday, September 19, 2007 2:55:43 PM         
   


> >
> > Stewart,
> >
> > The first thing I note is your GetNewKey() function. You are using VFP 9, so just make your key fields autoinc fields. Let VFP handle the new key assignment for you. I also note that you do not unlock the record in that function. If you lock a record or table, you MUST unlock it, or other users will never be able to add a new record.
> >
> > In your CmdGrid.PRG, you are programmatically creating a form and a button class. Why not just build the form and class visually and then run them? It would be a lot easier to maintain. They call it Visual FoxPro for a reason.
> >
> > As to your forms, I cannot open them without your skin classes.
> >
> >
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)
>
> Dear Ken,
>
> Below attachment is my skin classes.
>
> http://www.foxite.com/uploads/16613d09-ad81-45f1-be28-abeb9395241f.zip
>
> Regards,
>
> Stewart Chew

Stewart,

The first thing I am going to suggest is that you need to get rid of all of those public variables. There are VERY few places where you need to use a public variable. For example,

* In your form mInsMtrl's .Load() you have:
PUBLIC mMrsValid, mMtrlCode, mMtrlDesc, mMrsSrch, mTl_iss, mTl_rtn, mBomQty


The idea in object oriented coding is that each object should contain everything it needs to function. If it needs a public variable, then it does not have everything it needs - the public variable is outside of the object.

I don't have your tables, so when I load up the forms, VFP cannot find the tables and it pops an error message. I simply ignore those messages in order to look at your code. Unfortunately, this means that I cannot look at your table properties. From the look of it, I don't think you are using table buffering. Ealier, I recommended that you read my article here:

http://www.foxite.com/articles/read.aspx?id=75&document=moving-from-single-user-to-multiuser-in-vfp

In order for you to use transactions you need to have buffering enabled. Start by reading that article and then simply play with it. Start simple with a single table, set the buffermodeoverride to 5 and become familliar with how to use buffering. When you feel comfortable, add a child table, set it's buffering to 5 and create a transaction in your update.

I also note that you do not give your controls meaningful names. For example, you have "Command1" in all of your forms. Give these controls meaningful names like "SaveCmd" and "RevertCmd." This will make your code much more readable.

If I may, I would recommend that you get the following book:

http://www.hentzenwerke.com/catalog/fund6.htm

While it was written for VFP 6, the fundamentels remain unchanged and I recommend this book even if you are working in VFP 9

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)



COMPLETE THREAD
Insert & Update records Posted by Stewart Chew @ 9/13/2007 8:47:55 AM
RE: Insert & Update records Posted by tushar @ 9/13/2007 10:12:55 AM
RE: Insert & Update records Posted by Stewart Chew @ 9/13/2007 11:33:53 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/13/2007 12:40:19 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/18/2007 3:54:33 AM
RE: Insert & Update records Posted by tushar @ 9/18/2007 11:44:22 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/18/2007 2:12:41 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/19/2007 2:39:21 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/19/2007 2:55:43 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/20/2007 4:18:16 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 1:45:31 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:05:02 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:14:16 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:26:32 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:43:10 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:00:53 PM