Normal Topic Post data to 5 Form LE's in External App (Read 614 times)
Stew Bell
Member
*
Offline



Posts: 21
Joined: Dec 17th, 2011
Post data to 5 Form LE's in External App
Dec 22nd, 2011 at 5:22am
Print Post Print Post  
I have a form for "Expenses by Cash&Check" that will fill "Pay to" "Address" "City" "Prov" "pc" by Xlookups on a unique "Vender#" from an external Contacts.db in a different application.

I have the code to determine if the "Pay to" string is in the "company" field in the Contacts.db

I would like to be able to program a command button? to autofill a new record in Contacts.db with the Pay to, Address, City, Prov, Pc fields that were just added to the "Expenses by Cash&Check" db and assign a new unique "vender#" to it.

My Vender Numbers consist of the first two letters of the "Pay to" Company and three digits following.
eg.  General Motors could be GE112...at&t=AT125

Too many operations for my limited knowledge.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Post data to 5 Form LE's in External App
Reply #1 - Dec 22nd, 2011 at 2:30pm
Print Post Print Post  
Stew Bell wrote on Dec 22nd, 2011 at 5:22am:
My Vender Numbers consist of the first two letters of the "Pay to" Company and three digits following.
eg.  General Motors could be GE112...at&t=AT125


Where are the three digits coming from?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Stew Bell
Member
*
Offline



Posts: 21
Joined: Dec 17th, 2011
Re: Post data to 5 Form LE's in External App
Reply #2 - Dec 22nd, 2011 at 3:55pm
Print Post Print Post  
There is no specific format for the number.  It just needs to be unique.
I started with the first two letter of the venders name and 100 and just incremented from there.

Stew
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Post data to 5 Form LE's in External App
Reply #3 - Dec 22nd, 2011 at 4:55pm
Print Post Print Post  
I don't have your applications, so I can't test or look up the names of your fields and such, but it would go something like this.

Code
Select All
#include "sbasic_include.sbas"    // This line should go in GLOBAL CODE

var vNum as Int
var vVendor as String
var vRS as Int

	vNum = @ToNumber(@GlobalValue("LastVendor"))		// Get the last used vendor id
	If vNum < 199 vNum = 199				// Enforce a start value of 200
	vNum = vNum + 1						// Increment vendor id
	GlobalValue("LastVendor", @Str(vNum))			// Put new value into LastVendor for next time

	vVendor = @Left(PayTo, 2) + @Str(vNum)			// Assemble the new Vendor Number

	// Open an external resultset. You may need to change the name/path of the application/database/fields to match
	// what you have. I'm also assuming that there are no records with a blank vendor number because I want an
	// empty resultset.
	vRS = @XResultSetSearch("Contacts.db", "Contacts", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!VendorNumber==")
	if(vRS > -1)
	{
		XResultSetCreateNewRecord(vRS)			// Make a new record
		XResultSetValue(vRS, "VendorNumber", vVendor)	// Fill in all the fields
		XResultSetValue(vRS, "PayTo", PayTo)
		XResultSetValue(vRS, "Address", Address)
		XResultSetValue(vRS, "City", City)
		XResultSetValue(vRS, "Prov", Prov)
		XResultSetValue(vRS, "pc", pc)
		XResultSetClose(vRS)				// Close the ResultSet
	} 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged