Back to forum list… Back to How Do I?...

Check if Vendor code from Database exists in a Lookup using Optional field & IDGRP concatenation (3 replies)

Llewellyn Victor
10 years ago
Llewellyn Victor 10 years ago

In the source dataset the vendors are called Parties, and each branch gets the same PartyCode (XIDPARTY), but they are set up at different times, so when a branch sets up the party it might already be in accpac, so instead of me assigning the next number from the counter I want to check if the account might already exist based on a concatenation of the XIDPARTY field and the IDGRP, because the party might be in different currencies in which case it gets a different number.

So if the DB XIDPARTY&IDGRP = The XIDPARTY&IDGRP Lookup, then I want to use that vendor or if it does not exist then assign a number from the counter.

Support
10 years ago
Support 10 years ago

Hi Llew,

As discussed, did you get the Lookup working in SQL Management studio first?

Could I get a look at the query?

Nick

Llewellyn Victor
10 years ago
Llewellyn Victor 10 years ago

Hi Nick  yes, I did.  See below: This returns the correct values as expected, and then I would look up the IDGR&XIDPARTY (INVCHLOR01IAH) and return the vendor number, and then use the vendor number for any new records where IDGRP = INV and XPARTYID = CHLOR01IAH

Query:

SELECT dbo.APVEN.VENDORID, dbo.APVEN.IDGRP, dbo.APVENO.OPTFIELD, dbo.APVENO.VALUE

FROM dbo.APVEN INNER JOIN

dbo.APVENO ON dbo.APVEN.VENDORID = dbo.APVENO.VENDORID

WHERE (dbo.APVENO.OPTFIELD = 'XIDPARTY')

Support
10 years ago
Support 10 years ago

Llew, I think you could alter the SQL/Lookup to:

SELECT  dbo.APVEN.VENDORID, dbo.APVEN.IDGRP, dbo.APVENO.OPTFIELD, dbo.APVENO.VALUE<br>FROM  dbo.APVEN INNER JOIN dbo.APVENO ON dbo.APVEN.VENDORID = dbo.APVENO.VENDORID and dbo.APVENO.OPTFIELD = 'XIDPARTY'<br>WHERE ON.VALUE = '%1' and APVEN,IDGRP = '%2'<br>
SELECT  dbo.APVEN.VENDORID, dbo.APVEN.IDGRP, dbo.APVENO.OPTFIELD, dbo.APVENO.VALUE<br>FROM  dbo.APVEN INNER JOIN dbo.APVENO ON dbo.APVEN.VENDORID = dbo.APVENO.VENDORID and dbo.APVENO.OPTFIELD = 'XIDPARTY'<br>WHERE ON.VALUE = '%1' and APVEN,IDGRP = '%2'<br>

Note here the two parameterised values %1 and %2...this is how to parameterise the query.

Then your lookup function would look like:

Lookup("LOOKUPID", "VENDORID", Array(%XIDPARTY, %IDGRP), False)
Lookup("LOOKUPID", "VENDORID", Array(%XIDPARTY, %IDGRP), False)

Note that we're passing in two values as parameters into the Lookup...these are two fields enclosed in the Array.

Contact

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Request Demo

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Access Downloads

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close