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

Accpac Finder in VB.NET (on Windows 7, 64 bit) not working 1

Status
Not open for further replies.

caret

Vendor
Nov 12, 2012
7
Hi there. New to this site (as a member, at least). Just wondering if anyone has encountered what I'm up against:

For some reason I can't get the AccpacFinder to work in VB.NET (on a Windoze 7, 64 bit w/s, incidentally). I gives me a not so helpful "Error HRESULT E_FAIL has been returned from a call to a COM component." This code works fine in VBA (and VB6, if I recall). This is Accpac v5.5 SP2... I know, out of date, but that's what my client is using.

Public Sub StartFinder()
Dim f As New AccpacFinder.ViewFinder
Dim arr(1) As Array ' new

f.Session = Session ' AccpacSession
f.ViewID = "AR0032"
f.Filter = "TEXTTRX=1"
f.ReturnFieldIDs = 1 ' System.Array(1) ' arr(1)

If f.Finder = True Then Form1.txIDINVC.Text = f.ReturnKeyValues ' <-- This is where it errors out.
' A problem with the result
' f.Finder returns?

End Sub

Thoughts?
 
Here's the code that I've used for a 32-bit app running on a 64-bit OS

Code:
        Dim fnd As New AccpacFinder.ViewFinder
        Dim VisibleFields() As Integer = {1, 3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
        fnd.Session = Session
        fnd.ViewID = "GL0001"
        fnd.DisplayFieldIDs = VisibleFields
        fnd.ReturnFieldIDs = 1
        If fnd.Finder = True Then
            ExcelApp.ActiveCell.Value = "'" & Trim(fnd.ReturnFieldValues)
        End If
        fnd = Nothing
 
Thanks for the speedy reply! I tried your code and also errored out on the "If fnd.Finder = True" line.

Maybe it's my session? My session works fine with other API calls, so i don't know WHY that would be an issue, but stranger things have happened.

I am no using the signon manager, just the session manager:

Session.Init("", "XY", "XY0001", "60A")
Session.Open("ADMIN", "ADMIN", "SAMLTD", CDate(Now()), 0, "")
mDBLinkCmpRW = Session.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READONLY)
If IsNothing(Session) Then Return False

PS: Is this Django?
 
Try your code again but use
Code:
.ReturnFieldValues
instead of
Code:
.ReturnKeyValues
and see if that helps.

PS: Yes. :)
 
I've tried both... I just forgot to change it back to the usual, working ReturnFieldValues.

I don't know what else to try. I don't have another v5.5 install handy. Maybe i'll compile it and see if it works on my client's computer.

PS: This is Scott from Plus... I'm back in the Accpac game. (I used to talk to you on the phone occasionally... a hundred years ago or so.)
 
Hey Scott - good to hear from you again.

Try wrapping the code in a try..catch and see if there are any better error messages to read.

As for your Session calls - don't forget that sample data is in 2019 and 2020 so your call:

Code:
Session.Open("ADMIN", "ADMIN", "SAMLTD", CDate(Now()), 0, "")

Will cause you problems.

Also - go with a READWRITE connection to the database until you solve the other problem - just in case.
 
Oops - I forgot this is 5.5 that you're on.

change your .ini to use "55A" for the last parameter. Not likely the issue but it won't hurt.
 
The connection information is corrected per your post. (I'm actually using my client's data with today's date but, for some reason, felt compelled to change the database ID to protect the innocent. :-\ Not that anybody would ever recognize it.)

I tried putting a try/catch in the finder routine and the build now crashes when I hit the finder button: "vshost32-clr2.exe has stopped working".

 
Yes. Although I regacc'd this install and made sure my references were pointing to this dll, etc.

I will see if other AccpacFinder.dll's reside on this computer and rename them. I'll report back on how that goes.
 
Check your path - if it is pointing to a different version of Accpac RUNTIME folder before the version you're trying to run then that will cause problems.
 
The reference in the VB.net project is definitely pointing to the correct path. But i'm so desperate, i'm going to rename the others - just in case.
 
I've come into issues with DEP and the Accpac Finder with VB.net

Open a Visual Studio Command Prompt and enter EDITBIN /NXCOMPAT:NO "<FILEPATH>
 
1) Turn Off DEP
run command: debedit.exe /set {current} nx AlwaysOff
2) Reboot
3) Turn UAC all the way down
 
@mlnick: that worked like a charm! I think I'd rather do this than turn off DEP completely.

The only issue is, how can i run this with every compile as I am debugging/testing along the way all the time.
 
Use Post Build Events

In Visual Studio go to the properties of your project. Click on "Compile" (left side of the screen)

There's a "Build Events..." button. Put the following in the "Post-build Event Command Line" section:

call $(DevEnvDir)..\tools\vsvars32.bat
editbin.exe /NXCOMPAT:NO $(TargetPath)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top