Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Autoselect dao version when form is open

Posted on 2002-05-29
8
Medium Priority
?
300 Views
Last Modified: 2012-06-22
His is actually a continuation to my PAQ "connecting outlook to sql server"

Here's the problem, I have the following code working, but when a workstation have the new DAO that is not compatible with the old one, I would like to have the form autoselect the connection for me.  The coding goes as follows (with arrows pointing at the error)


Option Explicit
'Script level declarations
Dim dbe
Dim wrkODBC
Dim conDB
Dim Rs
Dim gstrAppName
'Dim page objects and control collections
Dim objPage
Dim objControls
Dim objPagePO
Dim objControlsPO
'DAO constants dim
Dim dbUseODBC
Dim dbDriverComplete
Dim dbDriverNoPrompt
Dim dbDriverPrompt
Dim dbDriverCompleteRequired
Dim dbOpenSnapshot
Dim dbOpenForwardOnly
Dim dbOpenDynamic
dbUseODBC=1
dbDriverComplete=0
dbDriverNoPrompt=1
dbDriverPrompt=2
dbDriverCompleteRequired=3
dbOpenSnapshot=4
dbOpenForwardOnly=8
dbOpenDynamic=16
dim MyNum

Dim txtOrderID

Sub Item_open()
Dim curExtension
Dim lngOrderID
Dim i
Dim strSQL
If Not (GetODBCConnection("autonum","ODBC;DSN=SMS",dbDriverCompleteRequired)) Then
    Exit Sub
End If
strSQL = "Select ID from autonum"
set Rs = conDB.openrecordset(strsql,dbopensnapshot)
'rs.movelast
rs.movefirst
mynum = rs(0)
Set objPage = Item.GetInspector.ModifiedFormPages("General")
Set objControls = objPage.Controls                                  
Set txtOrderID = objControls("txtOrderID")              
if txtorderid.text = "0" then
  strSQL = "update autonum set id = id + 1"
  conDB.execute strSQL
  txtOrderID.text = mynum
end if
End Sub

Function GetODBCConnection (ByVal MyDSN, ByVal MyConn, ByVal MyPrompt)
Dim strUser
Dim strPass
Dim dbUseODBC
'Must assign values to constants in VBScript
dbUseODBC=1
strUser=""
strPass=""
Set dbe= Item.Application.CreateObject("DAO.dbEngine.35") <~~~~~~~ error over here
Set wrkODBC = dbe.CreateWorkspace("ODBCworkspace", strUser, strPass, dbUseODBC)
dbe.Workspaces.Append wrkODBC
Set conDB = wrkODBC.OpenConnection("Connection1", MyPrompt, , MyConn)
GetODBCConnection = True
End Function

Function Item_Close()
conDB.Close
wrkODBC.Close
End Function
0
Comment
Question by:nl4jy
  • 5
  • 3
8 Comments
 
LVL 8

Accepted Solution

by:
jessnjeff earned 400 total points
ID: 7043317
You are stuck because of the funky (non)error handling available in a form.

Try adding ON error resume next in your function, then add

code here for your error

Set dbe= Item.Application.CreateObject("DAO.dbEngine.35") <~~~~~~~ error over here

if err.number <> 0 then Set dbe= Item.Application.CreateObject("DAO.dbEngine.36")
0
 
LVL 1

Author Comment

by:nl4jy
ID: 7044856
Okay, I tried that, but now, when I tried to open up the form, I have the following error on the new boxes:

Can't load DLL: 'MSRDO20.DLL'
on the same error line.

Any idea what this mean and how to fix it?
0
 
LVL 1

Author Comment

by:nl4jy
ID: 7044869
Oops, actually it's the next line over.  at

Set wrkODBC = dbe.CreateWorkspace("ODBCworkspace", strUser, strPass, dbUseODBC)
0
Industry Leaders: 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!

 
LVL 1

Author Comment

by:nl4jy
ID: 7044962
Oops, actually it's the next line over.  at

Set wrkODBC = dbe.CreateWorkspace("ODBCworkspace", strUser, strPass, dbUseODBC)
0
 
LVL 1

Author Comment

by:nl4jy
ID: 7044994
Never mind, that fixed it, I didn't publish the form so the new code didn't save.  Thanks.  but before I hand these points over, if you know what the msrdo20 error is, please do tell.  Thanks again.
0
 
LVL 8

Expert Comment

by:jessnjeff
ID: 7045079
I got a reference to it in VS and it is the MS Remote Data Object 2.0.
0
 
LVL 1

Author Comment

by:nl4jy
ID: 7045234
That's fine.  As long as this program seems to be working, U deserve the points.  Thanks.
0
 
LVL 8

Expert Comment

by:jessnjeff
ID: 7045263
Thank you
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

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

927 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