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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Replace Data To Another Table With Conditions 1

Status
Not open for further replies.

wrgt9740

Programmer
Dec 5, 2020
35
PH
Hi. I have two tables named tblItems and tblReport, and I'd like to replace the data of tblReport with tblItems so I could see the comings and goings of a specific item.

tblItems has fields Date, Item, Quantity, and Status. Status is either "I" for incoming, or "O" for outgoing. Quantity represents the number of items incoming / entering warehouse, or outgoing / leaving warehouse.
tblReport has fields Date, Incoming, and Outgoing. Both Incoming and Outgoing fields are number types.

What I wished to do was to generate a summary of movement of a specific item, for example "ballpen", from tblItems, then copy the Date to tblReport where there was an entry of "ballpen".

Data for Incoming and Outgoing fields would depend on the Status: if the Status is "I", then Quantity of tblItems would be copied to Incoming of tblReport. If Status is "O", then Quantity would be copied to Outgoing. tblReport for "ballpen" would look like this:
[tab]DATE[tab][tab][tab]INCOMING[tab][tab]OUTGOING
[tab]01/15/20[tab][tab][tab]10
[tab]01/16/20[tab][tab][tab][tab][tab][tab][tab][tab][tab]2
[tab]01/17/20[tab][tab][tab][tab][tab][tab][tab][tab][tab]5
[tab]01/18/20[tab][tab][tab]10

Does anyone have suggestions on how to execute this efficiently? I was able to get the results I wanted, but it involved creating a cursor, INSERT INTO cursor, UPDATE cursor if Status is "I", UPDATE cursor if Status is "O", then finally INSERT INTO tblReport. This is the only way that I could think of, as I didn't receive any proper training on FoxPro, nor on other programming languages. I only educated myself through reading books from the Internet, and researching in forums.

Thank you for taking the time to read this.
 
Hi,

this hacker's guide to visual foxpro seems interesting. maybe I need to read it.

It is not only interesting it's a MUST for any serious VFP user/programmer. And don't forget to get the latest one "What's New in Nine: Visual FoxPro Latest Hits". You find them all at [link ][/url]

One more hint

If you want to make your FoxPro programs scream (and not vice versa) then the Hacker's Guide to Visual FoxPro is for you. (Overview of the Hacker's Guide to VFP 3.0 by T. Granor, T. Roche et al)

hth

marK
 
Thanks for all the kind words about the Hacker's Guide, folks.

@wrgt9740, you won't be able to buy a paper copy unless you can find it used. However, you can buy the ebook, which is in CHM format, from Hentzerwerke (hentzenwerke.com/). I keep a shortcut to it on my desktop and use it pretty much everyday that I'm working in VFP.

Tamar
 
Well, I would consider it as free since I can access all the information without spending money. I'm such a cheapskate.
 
Ah, right, we did open source the Hacker's Guide. I lost the thread of the conversation. 2020, you know?

Tamar
 
Hahaha! Yes, 2020 has affected a lot of people in various ways, including myself in numerous ways I could no longer count.
 
Thanks myearwood. You, and everyone's contributions are helping me learn more about Foxpro. I am currently in the process of changing my codes to use cursors instead of the programmer's tables in creating reports, and switching to reading the online version of the hacker's guide. I'm still far from done in creating a Foxpro version of the programmer's clipper.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top