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

Problems Copy an field value into a Array 2

Status
Not open for further replies.

PBREP

MIS
Mar 14, 2003
75
US
Hi All:

Using VFP 8.0

PROBLEM: Need my Swog Weight to rate.
SWOG stands for Ship With Other Goods. It is used to ship several smaller items within a larger container to the same destination. This information is stored in the shipping software I'm using, it lets you track which shipment a particular item was sent in.

USER PROCESS: User clicks on the Swog cmdButton, which launches a grid from the SWOG111.dbf. When the user clicks LIST from the grid, their products/records are displayed from the products.dbf. After the user clicks/selects a product, it then populates the grid/Swg111.dbf.

MY TASK: Attempting to do a Function that will take the data from the temp swog table (swog111.dbf) which is created during shipment processing screen(station1),and stuff the weight from Sw_anynum2 (Swog111.Sw_anynum2) into the weight field/array SC_SHIP.A_SHIP[8]on the shipping screen. Of course, this will only work for one swog record; later in the stage I will do a procedure in my cus_main.prg that will take all the weight and total it up then be stuffed.

ERROR: I hit Record then I receive a message box "Swog111.dbf is in use by another user/Application" click OK the another error "Error 12 Parent is not found

CODE:
FUNCTION Swg_weight()
Set exclusive off
Use swog111 in 0 again alias myAlias
*Locate for a particular record if needed
Sc_ship.a_ship[8] = myAlias.Sw_anynum2
EndFunc

I did try 'Set exclusive off' but that made no difference. I'm the only user. I think I know what the problem is, I am accessing SWOG111.dbf but not closing it so, after record the information from Swog gets written to the manifest table hence, its locked up. Do I need to close it? Other than that, I'm still not seeing my weight in my field (ref. Sc_ship.a_ship[8])

Any suggestions would be apreciated.
Thanks,
~PM
 
Hi ~PM,

USE IN SELECT("swog111") will close the table without throwing an error if the table is not open. If you have specified an alias use that instead of the table name.

What is Sc_ship.a_ship[8]? Array? Form property?

If you are using buffering, are you issuing TABLEUPDATE() so the changes are written to the table?

Regards,

Mike
 
Hi Mike:

Sc_ship.a_ship[8] is the array for the weight field on the shipping screen during runtime. I tried what you suggest but I get an "Error 13 Alias Swog111 is not found" ??? :(

FUNCTION Swg_weight()
Set exclusive off
USE IN SELECT("swog111")
Sc_ship.a_ship[8] = swog111.Sw_anynum2
EndFunc

~PM
 
Hi Mike:

Sc_ship.a_ship[8] is the array for the weight field on the shipping screen during runtime. I tried what you suggest but I get an "Error 13 Alias Swog111 is not found" ??? :(

FUNCTION Swg_weight()
Set exclusive off
USE IN SELECT("swog111")
Sc_ship.a_ship[8] = swog111.Sw_anynum2
EndFunc

~PM
 
Hi ~PM,

Have you applied SP1? What is the code that USE's swog111 - does it have an ALIAS clause? What happens when you execute this in the command window:
Code:
USE IN SELECT("junk")
My VFP8 SP1 does nothing.

What about the TABLEUPDATE() issue? Are you using buffering?

So, Sc_ship is the form's name?

Regards,

Mike
 
Hi Mike:

Thanks for sticking with me. I have no source code of the program (ref. Thirdparty shipping software). However, I have the ability to access "custom routines" by utilizing a program file called Cus_main.prg. Here I can code and in Screen Builders (ref. shipping software) I can make calls Functions, Procedures either on a particular field on the screen or in a module, that houses the Screen Parameters (i.e. "After getting shipping data", "After Record").

My VFP 8.0 has SP-1.
No Tableupdate() being used.
No buffering.

PS - Mike I can email a better decription along with a visual example (i.e SC_SHIP)if you like??? I think you would better understand what I'm getting at; let me know? Thanks.
~PM
 
Hi ~PM,

Don't know if the EULA would support it (third party), but mikeATcomtekDOTcom will get to me (replace the appropriate parts). You should be able to get help from them, though.

Could be a couple of other things. If the table is empty (no records) or if a seek or locate fails the record pointer will be at EOF() where there isn't a valid record.

Regards,

Mike
 
Good morning Mike:

Please let me now if you receive my file I sent to you this moring.

Thank you,
~PM
 
Hi ~PM,

Yup, got the file.

I think that swog111 in in exclusive use already and that is why your function isn't working.

Code:
FUNCTION Swg_weight()
LOCAL lcOldWorkArea
lcOldWorkArea = SELECT()
*Set exclusive off  && Dangerous to change in someone else's app
SELECT SWG  && just change to it
Sc_ship.a_ship[8] = Sw_anynum2  && no table name
SELECT(lcOldWorkArea)
EndFunc

I'm not sure that your UDF is available at run time. If cus_init is only called at initialization you may want to move your UDF and use SET PROCEDURE TO in cus_init to point to it.

You have no customer support?

Regards,

Mike
 
I would like the community all to know that Mike P. is one extraordinary fellow. For weeks, Mike provided his assistance off-line helping me resolve my issue. Mike offered some awesome insight on how to tackle the problem. Mike also went above and beyond by attempting to get his hands on the same third-party software (DEMO) I am using for himself for analysis. If I can select another 4 stars on this post I would.

Thanks again Mike
~PM
 
This is how "our" VFP community is and should be. Kudos to Mike.
One last thing, If your posted problem has been resolved, with or without the help of the VFP community, post the solution to the problem. It is the least that one can do to show appreciation for the help and effort provided by this forum.

edgar
 
Hi Paul,

Thanks, glad it's working.

Hi Edgar,

The solution wasn't a VFP thing. It was specific to the program Paul was working with (Pitney Bowes - Ascent.exe). So posting the solution wouldn't add to the comunity.

I have learned more than I can ever give back in this, and other forums.

Regards,

Mike
 
&&WORKING CODE
LOCAL lnOldWorkArea, llOKToClose
lnOldWorkArea = SELECT()

IF SELECT("Swog111") > 0
SELECT Swog111
llOKToClose = .F.
ELSE
SELECT 0
USE c:\ascent\swog111.dbf AGAIN&& Allows multiple open unless the Shipform has it open EXCLUSIVE
llOKToClose = .T.
ENDIF

Sc_ship.a_ship[9] = Sw_anynum2
MESSAGEBOX(Sc_ship.a_ship[9])&& For testing purposes
IF llOKToClose
USE
ENDIF

SELECT(lnOldWorkArea)
Return .T.
smiletiniest.gif
 
Fine Mike,Keep up the good work. My message was not directed to you or this thread specifically, but to anybody who found a solution to a problem and failed to post it.
This way, everybody benefits of this knowledge.
Regards,
edgar
 
There are a few unnecessary things I'd change in the coded solution posted, though I must admit I don't understand the need for the swog111 table to be opened since it is not used in the code.

Code:
Local lnOldWorkArea, llOKToClose

lnOldWorkArea = Select()
llOKToClose = !Used("Swog111")

If llOKToClose
	Use c:\ascent\Swog111.Dbf IN 0 Again
ENDIF

SELECT("Swog111")

Sc_ship.a_ship[9] = Sw_anynum2

Messagebox(Sc_ship.a_ship[9])&& For testing purposes

If llOKToClose
	USE IN SELECT("Swog111")
ENDIF

Select(lnOldWorkArea)

Return .T.

boyd.gif

 
Hi Craig,

Sw_anynum2 is a field in swog111.dbf

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top