Solved

Covert VB6 code to VBA in MS Access 2007

Posted on 2010-08-20
11
703 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 13

Expert Comment

by:Surone1
ID: 33488438
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
ID: 33488606
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
ID: 33488827
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 13

Expert Comment

by:Surone1
ID: 33491858
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
ID: 33492471
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
 
LVL 13

Expert Comment

by:Surone1
ID: 33492614
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
ID: 33492625
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
ID: 33500283
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
ID: 33500590
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
ID: 33501232
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
ID: 33512747
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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