Selecting a database from a form checkbox

D

demo

I have inherited a visio project and I have no prior Visio Automation or VB
expereince. I have been given the task of updating some of the automation
that we use within our Visio. We have a button that runs a form that will
paste a Bill of Materials on the current page or its own page or whatever the
user selects on the form.

We have an old and a new database(Access). When we pull up the old drawings
and run this Bill of Material builder it uses the new database and can not
find all of the parts and the ones it does find are not correct.

I have added a checkbox to the form that when checked would tell the program
to look at the old database or old table. I have tried it both ways. I have
been trying to switch the DB with an if else statement. It does not switch
although the syntax seems to be correct.

I added the line:
if frmDropOn.ChKDatabase.Value = true then
set...

I tried creating string variables for path2 and table2, I have not had any
luck.

Here is the original code if anyone can help me out.

Thanks,

Derek


Public docobj As Visio.Document
Public appvis As Visio.Application
Public objwks As DAO.Workspace

Public db As DAO.Database
Public rec As DAO.Recordset

Public column As String
Dim path As String
Dim table As String
Public hopie As Double

Public Sub Visio()

Set docobj = ThisDocument.Application.ActiveDocument
Go.ok = True

End Sub

Public Sub Access()
Call Getpath
Call Validate
End Sub

Public Sub Validate()

hopie = 0
On Error Resume Next
Set objwks = DAO.DBEngine.CreateWorkspace(" ", "Admin", "")
Set db = objwks.OpenDatabase(path)

If db Is Nothing Then
MsgBox " The Database Does Not Exist At
" & (path) & " - " & (table) & " Correct The
Settings In Program Options"
Go.ok = False
hopie = 1

Else
Set rec = db.OpenRecordset(table)
End If

End Sub

Public Sub Getpath()
path = "C:\Program Files\Microsoft Office\Visio11\CSC\Bill of
Material.mdb"
table = "Master BOM"
column = "Tag"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top