Solved

Covert VB6 code to VBA in MS Access 2007

Posted on 2010-08-20
11
698 Views
Last Modified: 2012-05-10
Can anyone help me to convert a VB6 code into VBA to be used in Microsoft Access 2007?
Dim db As PwWkmSvr.PwDatabase

Dim aCWFMInvtMgr As CwFMInvtMgr.CwFmInventoryMgr

db = New PwWkmSvr.PwDatabase

db.Do_Login("wsd", "wsd", "Test")

Dim aCwDbUser As PwWkmSvr.CwDBUSER

aCwDbUser = New PwWkmSvr.CwDBUSER

aCwDbUser.Build(db, db.UserId)

aWOManager = New PwWkmCli.WorkOrderMgr

aCWFMInvtMgr = New CwFMInvtMgr.CwFmInventoryMgr

aWOManager.SetPwDb1(db, aCwDbUser, aCWFMInvtMgr)

aWOManager.ShowEditWoForm("10000035")

Open in new window

0
Comment
Question by:Cobra967
11 Comments
 
LVL 13

Expert Comment

by:Surone1
Comment Utility
access vba and vb6 code are basically the same. where does it go wrong? do you have the right references?


wihout adding references you could also try the following.

Dim db As object
Dim aCWFMInvtMgr As object
set db = Createobject("PwWkmSvr.PwDatabase")

0
 

Author Comment

by:Cobra967
Comment Utility
It breaks at each point. What reference do I need to add? The code supposeli opens anothe databse written in VB6, log in the system and go to the search page...
0
 
LVL 84
Comment Utility
Looks like you'd need a couple of references, at the least:

PwWkmSvr
CwFMInvtMgr

However, the code suggested by Surone1 would be preferable, since it would require no references.
0
 
LVL 13

Expert Comment

by:Surone1
Comment Utility
question was answered. and it should be doable using my method if the code works in vb6
or by checking the references of the vb6 project and adding the 2 in the acces project.
if it doesnt, asker would neeed the components which i fail to find on the internet :-(
0
 

Expert Comment

by:shrimantpatel
Comment Utility
Please look at the below sample...two line conversion...do the same with the rest of the lines and try


Dim db 'As PwWkmSvr.PwDatabase

set db = Createobject("PwWkmSvr.PwDatabase")

Dim aCWFMInvtMgr 'As CwFMInvtMgr.CwFmInventoryMgr

set db = Createobject("CwFMInvtMgr.CwFmInventoryMgr")

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:Surone1
Comment Utility
Dim db As object
Dim aCWFMInvtMgr As object
set db = createobject("PwWkmSvr.PwDatabase")
db.Do_Login("wsd", "wsd", "Test")
Dim aCwDbUser As object
set aCwDbUser =  createobject("PwWkmSvr.CwDBUSER")
aCwDbUser.Build(db, db.UserId)
aWOManager = createobject("PwWkmCli.WorkOrderMgr")
aCWFMInvtMgr = createobject("CwFMInvtMgr.CwFmInventoryMgr")
aWOManager.SetPwDb1(db, aCwDbUser, aCWFMInvtMgr)
aWOManager.ShowEditWoForm("10000035")
0
 
LVL 13

Expert Comment

by:Surone1
Comment Utility
Dim db As object
Dim aCWFMInvtMgr As object
set db = createobject("PwWkmSvr.PwDatabase")
db.Do_Login("wsd", "wsd", "Test")
Dim aCwDbUser As object
set aCwDbUser =  createobject("PwWkmSvr.CwDBUSER")
aCwDbUser.Build(db, db.UserId)
set aWOManager = createobject("PwWkmCli.WorkOrderMgr")
set aCWFMInvtMgr = createobject("CwFMInvtMgr.CwFmInventoryMgr")
aWOManager.SetPwDb1(db, aCwDbUser, aCWFMInvtMgr)
aWOManager.ShowEditWoForm("10000035")
0
 

Author Comment

by:Cobra967
Comment Utility
When compiling, I am getting the following errors messages:
db.Do_Login("wsd", "wsd", "Test") --I am getting a Syntax Error
aCwDbUser.Build(db, db.UserId) -- I am getting a Syntax Error
Set aWOManager ... -- I am getting a variable not defined
aWOManager.SetPwDb1(db, aCwDbUser, aCWFMInvtMgr) -- I am getting a variable not defined
aWOManager... -- I am getting a variable not defined
0
 
LVL 13

Accepted Solution

by:
Surone1 earned 500 total points
Comment Utility
Dim db As Object
Dim aCWFMInvtMgr As Object
Set db = CreateObject("PwWkmSvr.PwDatabase")
db.Do_Login "wsd", "wsd", "Test"
Dim aCwDbUser As Object
Set aCwDbUser = CreateObject("PwWkmSvr.CwDBUSER")
aCwDbUser.Build db, db.UserId
Dim awomanager As Object
Set awomanager = CreateObject("PwWkmCli.WorkOrderMgr")
Set aCWFMInvtMgr = CreateObject("CwFMInvtMgr.CwFmInventoryMgr")
awomanager.SetPwDb1 db, aCwDbUser, aCWFMInvtMgr
awomanager.ShowEditWoForm ("10000035")
0
 

Author Comment

by:Cobra967
Comment Utility
This is great! I can log in to the database and open the desired record. However it re-close the just loaded record as soon it is loaded. I know probably I am asking too much, but do you have any idea why is doing this?
0
 
LVL 13

Expert Comment

by:Surone1
Comment Utility
glad it works, i have no idea what the component does, so i'm affraid i cant help with that.
maybe you can figure out how by setting a breakpoint in the code, and adding watches for the object.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now