• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 714
  • Last Modified:

Covert VB6 code to VBA in MS Access 2007

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
Cobra967
Asked:
Cobra967
1 Solution
 
Surone1Commented:
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
 
Cobra967Author Commented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
Surone1Commented:
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
 
shrimantpatelCommented:
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
 
Surone1Commented:
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
 
Surone1Commented:
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
 
Cobra967Author Commented:
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
 
Surone1Commented:
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
 
Cobra967Author Commented:
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
 
Surone1Commented:
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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now