Solved

Covert VB6 code to VBA in MS Access 2007

Posted on 2010-08-20
11
704 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

707 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