Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Covert VB6 code to VBA in MS Access 2007

Posted on 2010-08-20
11
Medium Priority
?
709 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 85
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

610 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