Mmonth=1 Select 7 Use Banks Select 6 Use Trial Select 7 Goto Top SCAN While (!Eof()) bank_code= Banks.bankcode bank_head= Banks.accode Select 6 Locate For bank_code = Trial.bankcode .And. bank_head = ; Trial.accode If (!Found()) Select 7 Append Blank Replace Banks.bankcode With bank_code Replace Banks.accode With bank_head Endif Select 6 Do Case Case Mmonth == 4 Newob= Trial.debit_4 Case Mmonth == 5 Newob= Trial.debit_5 Case Mmonth == 6 Newob= Trial.debit_6 Case Mmonth == 7 Newob= Trial.debit_7 Case Mmonth == 8 Newob= Trial.debit_8 Case Mmonth == 9 Newob= Trial.debit_9 Case Mmonth == 10 Newob= Trial.debit_10 Case Mmonth == 11 Newob= Trial.debit_11 Case Mmonth == 12 Newob= Trial.debit_12 Case Mmonth == 1 Newob= Trial.debit_1 Case Mmonth == 2 Newob= Trial.debit_2 Case Mmonth == 3 Newob= Trial.debit_3 Case Mmonth == 13 Newob= Trial.debit_31 Case Mmonth == 14 Newob= Trial.debit_32 Endcase Wait Window bank_code Wait Window bank_head Wait Window Newob Select 7 Replace Banks.ob With Newob Select 7 ENDSCAN <pre> Both the above DBF can be downloaded from <a href=https://www.dropbox.com/s/7reelvvjuix9k9u/DBF.zip?m target="_blank">https://www.dropbox.com/s/7reelvvjuix9k9u/DBF.zip?m</A> Regards Harsh >Sorry for not providing any help to your specific reason, instead I will give you some well meant advices. If you follow these advices, it will also be much easier to help you without twisting our minds too much. I realize that you are relatively new to VFP, I give you these advices with no other things in mind than giving you help. Follow these advices, and you will find VFP programming much easier: > >1. When you post code here, use < pre > before your code and < pre > after the code. (remove the extra space between < and >, I must use a space here or UT will hide what I really write.) >2. NEVER hardcode a work area, meaning NEVER use "select 5" or some other number. Always use a work area name, whenever necessary. Instead of "Use 7" to select an empty work area, use "Select 0" which will select the next availbale work area. When you need to reselect another work area which already have a table open, you can "Select yourtable" instead. This solution is both safer and much easier to use. Your code should never rely on a table being opened in a specific work area. >3. Learn SQL syntax. Select, Update and Insert are the most used SQL commands, they will with one line of code do the same as many lines of procedural code, and usually much faster. In this case you can use the appropriate "Update ... from ... where ..." commands instead of a lot of "do while .. Replace .. enddo" commands. And use "Insert into .." instead of "Append blank" followed by "replace .." >4. If you need to scan a table, and there are many cases where this makes sense, I recommend Scan .. Endscan instead of Do while !eof(). >5. When you have a problem with your code, only show the offending code, unless you think it's clear that we need to see it all. >6. Please enable "auto quote", unless you already have done so, it makes later messages easier to respond to. You find this option in the upper right corner of this message area. Just hover your mouse over the label "Message view setup", and you will see it. > >And last, always indent your code, something like this, which makes your code much easier to follow:<pre> > >Do while something > If something > do something > some more code > do case > case 1 > some code > case 2 > some more code > otherwise > do something else > endcase > even more code > Else > Do nothing > Endif > Some more code >Enddo>