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

Getting Vars from Differant FreeTables...

Status
Not open for further replies.

PogoWolf

Programmer
Mar 2, 2001
351
US
Hello all, I've having a bit of an issue (again.. why else would I be here? hehe)

WHat I'm trying to do is pull data from one Free Table, and insert it into another table.

Here's the Code:

Use Table1

IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1))) = "W" then
STORE Table1.Wque TO WorkNum
else &&ok, is an 'X'
STORE Table1.Xque TO WorkNum
Endif

Use Table2
REPLACE Table2.WorkNum WITH WorkNum

BUt these doesn't seem to work.. The reports are returning nothing but blanks...
---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
Hello

The variable has the same name with the field. This is your problem. Change the variable name or use GATHER MEMVAR FIELDS WorkNum

Hope this helps
Grigore Dolghin
Class Software
Bucharest, Romania
 
Use the "m." prefix to indicate variable names instead of field names. Your code would look like this:

Use Table1

IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1))) = "W" then
STORE Table1.Wque TO m.WorkNum
else &&ok, is an 'X'
STORE Table1.Xque TO m.WorkNum
Endif

Use Table2
REPLACE Table2.WorkNum WITH m.WorkNum
 
HI,
I've tried both ways, and it still doesn't seem to work...

I've played with the code and here's the 'current' version

Use wxNum
IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1))) = "W" then
STORE wxNum.Wque TO m.WorkNumTemp
else &&ok, is an 'X'
STORE wxNum.Xque TO m.WorkNumTemp
Endif

Use HealthBATCH
REPLACE HealthBATCH.WorkNum WITH STR(m.WorkNumTemp)


COuld the STR be causeing the issue?

---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
** Just copy the following code and see the result..

USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH ;
IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", ;
STR(wxNum.Wque), STR(wxNum.Xque))

** Your problem could be because (a) BUFFERING type and no TABLEUPDATE done .. (b) Second Table or First table record pointer is out of range.. (probably you should get a record out of range error for this.)

Any way try the code and let us know.. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
ok I've played again with the code.. but I'm running into a non-realted issue, that I'm pulling my hair out on..

Code:
STORE WorkNumTemp+1 TO WorkNumTemp

but when FoxPro hits this line.. it tell me there's an operator/operand error?

I believe (checking the DB's) that the code is working once I get this line to work..


---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
The field name used by you may be a character type.

STORE VAL(WorkNumTemp)+1 TO WorkNumTemp


ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
...and that's what I get for believeing.. LOL

ok, the STORE VAL worked. (I hate FoxPRO..LOL)
ok, here's the whole main part of the code:


&& Get's the Current Counter (as Per Queue)
&&&&&&&&&&&&&&&&&&&&&&
Close Databases
USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque))


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&& Update the Queue Counters
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Close Databases
USE wxNum IN 0 ALIAS wxNum

STORE IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque)) TO m.WorkNumTemp
STORE VAL(WorkNumTemp)+1 TO WorkNumTemp

Close Databases
USE HealthBATCH IN 0 ALIAS HealthBatch

&&UPdate the Count
&&&&&&&&&&&&&&&&&&&
IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1))) = "W" THEN
REPLACE HealthBATCH.Wque WITH WorkNumTemp
Else
REPLACE HealthBATCH.Xque WITH WorkNumTemp
Endif
Close Databases


this is the part that doesn't seem to work. The COunters (Xque/WQue in the XWNum table ARE being updated correctly..
the Current COunter is to be stored with each record.. (that's not happeneing)...

I am so lost at the moment..

---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
*******************************************
** Get's the Current Counter (as Per Queue)
**
Close Databases
USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque))
*******************************************
** Update the Queue Counters
Close Databases
USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
m.WorkNumTemp = ;
VAL(IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", ;
STR(wxNum.Wque),STR(wxNum.Xque)))+1
Close Databases
USE HealthBATCH IN 0 ALIAS HealthBatch
*********************************************
** UPdate the Count
IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1)))="W"
REPLACE HealthBATCH.Wque WITH m.WorkNumTemp
Else
REPLACE HealthBATCH.Xque WITH m.WorkNumTemp
Endif
Close Databases
***********************************************
Hope this works for you :)

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Hi... use this one.. ignore the last posting
*******************************************
** Get's the Current Counter (as Per Queue)
**
Close Databases
USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque))
*******************************************
** Update the Queue Counters
Close Databases
USE wxNum IN 0 ALIAS wxNum
GO TOP IN wxNum
m.WorkNumTemp = ;
VAL(IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", ;
STR(wxNum.Wque),STR(wxNum.Xque)))+1
Close Databases
*********************************************
** UPdate the Count
USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
IF ALLTRIM(upper(left(ThisForm.Combo1.Value, 1)))="W"
REPLACE HealthBATCH.Wque WITH m.WorkNumTemp
Else
REPLACE HealthBATCH.Xque WITH m.WorkNumTemp
Endif
Close Databases
***********************************************
Hope this works for you :)

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
IT didn't work.. well it didn't work 100% =)

The issues in this part of the code:
&&Get's the Current Counter (as Per Queue)
&&Store into WorkNum
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Close Databases
USE wxNum IN 0 ALIAS wxNum
USE HealthBATCH IN 0 ALIAS HealthBatch

If ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))= "W" THEN
REPLACE HealthBATCH.WorkNum WITH STR(wxNum.Wque,9)
ELSE
REPLACE HealthBATCH.WorkNum WITH STR(wxNum.Xque,9)
ENDIF
Close Databases


I've chopped it up a little for easier reading.

ALL the above (includeing the before messages) works now.. the frist time though. The code is set off buy a user pressing a button. The first time there's no problems.. the 2nd (or more) however, the .WorkNum comes back as blank.. =(


I do want to thank everyone for helping me on this!!!! =)
---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
I've always found that it's clearer and safer to either expicitly SELECT the workarea or add IN workarea to the REPLACE. For example intsead of:

USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque))

DO either:
USE HealthBATCH IN 0 ALIAS HealthBatch
SELECT HealthBatch
GO TOP && IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque))

OR

USE HealthBATCH IN 0 ALIAS HealthBatch
GO TOP IN HealthBatch
REPLACE HealthBATCH.WorkNum WITH IIF(ALLTRIM(upper(left(ThisForm.Combo1.Value,1)))="W", STR(wxNum.Wque), STR(wxNum.Xque)) IN HealthBatch

Rick


 
The above code works also.. Again the first time though. The way this program is set up, is that it will do all the above work when a user presses a button. THe FIRST time a user presses the 'add' button everything works fine. But when they add another record.. The above code doesn't seem to work.

I've checked the data itself, and it just like it's not getting into the FreeTable from the above code.. but it's only if the user hits the button more then once...

---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
FOr those Follwoing this Tread.. I think I figured out the issue (now to fix the codeing..hehe)

The Issues seems (read might be) that the 'get current Counter' section is going to the 'top' of the database.. so it's always going back to the first record!!! and that's why only the first record is working correctly.

so perhaps if I change the 'Go TOP in HealthBatch' to 'GO LAST(Bottom) in HEalthBatch'

this might fix it?
---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
YES!! that did it!!!!!!


Thank you again, to everyone that helped on this issue with me. =) =)

This site (and it's people) have been a god send to all of us 'newbies' and for those that just need help in thinking though our codeing problems.

Long Live Tek-Tips!!! ---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top