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

Get G/L account codes and names 2

Status
Not open for further replies.

aridif

Programmer
Jun 22, 2003
4
KE
how do i use VB to retrieve a list of G/L account names and codes. i would like to put the account codes in a comboBox.
 
1. Add a reference to the 'ACCPACXAPI 1.1 Type Library' To your project.

2. Create and open a xAPI session object.

Dim session As ACCPACXAPILib.xapiSession

Set session = CreateObject("ACCPAC.xapisession")
session.Open <UserName>, <Password>, <Database>, Date, 0

Username and Password are valid accpac usernames and passwords. Such as &quot;ADMIN&quot;, &quot;ADMIN&quot;. Database is your valid company ID. Such as &quot;SAMLTD&quot; for the ACCPAC sample company.

3. Decalare and open the view.

Dim GLACCOUNT As ACCPACXAPILib.xapiView
Set GLACCOUNT = session.OpenView(&quot;GL0001&quot;, &quot;GL&quot;)

4. Use the view to fill the combo box.

Combo1.Clear
With GLACCOUNT
.Init
.Order = 0
.Browse &quot;&quot;, True
Do While .Fetch
Combo1.AddItem .Fields(&quot;ACCTID&quot;).value
Loop
.Cancel
End With

5. Destroy the objects when not needed.

Set GLACCOUNT = Nothing.

That's it in a nutshell. If you have any errors or problems let us know. this was off the top of my head.

One thing, if you have a lot of accounts then your combo box might get pretty long. It might be better to use a finder like Accpac does.




Thanks and Good Luck!

zemp
 
The ACCTID are the unformatted account numbers. If you want to use the formatted account numbers substitute &quot;ACCTFMTTD&quot; for &quot;ACCTID&quot; in the code.

Thanks and Good Luck!

zemp
 
Hi Zemp,

I followed your instructions as above but to load my "Contract No". My problem is the contract no is of string value and it is not sorted when it is loaded to the combo box. Is there anyway i can sort my combo box data???

Please Help!!!
 
Set the Combo Box's .Sorted property to True.

If that doesn't work or takes to long then try the following.

1. Load the values into an string array.
2. Sort the array using a bubble sort (if not too big) or a shell sort.
2. Load the combo box with the sorted array.

See thread222-100795 for an example of the bubble sort and a link to example of other sorts including the shell sort.

zemp
 
Hi,

The combo box that i need to populate will be quite a list.
I'm just wondering if there is a better way....

Can i create an sql view instead and load the combo box based on the views data...?

If it is possible, could somebody teach me how i could populate the combo box with my views????

Please Help....
 
I like to use a custom ACCPAC finder. Depending on the objects you use you can add a reference to an ACCPAC control or you can use a class and a form as part of your project. See thread631-621905.

zemp
 
Hi Zemp,

I'm trying to import the finderfrm from the bas project into my project but keep hitting error. the error logged in the finderform.log file as as follows:

Line 2: Property OleObjectBlob in FinderForm could not be set.

Any idea why????
 
Check the references for the macro to see if there is something it is referencing that you are not. If so you will need to reference it or remove it from the form.

I would expect that some minor changes may need to be done. I don't think that all of the forms controls are standard controls. One of them is a Rich text box. For Win98 that control needs to be replaced with a standard text box.

If you are still stuck post the line of code that is throwing the error.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top