vba differences between access 2000 and access 2003

D

Dave F

A colleague created a db using access 2003 but saved it in access 2000
format, since most access installations here use Access 2000.

Everything seems to work fine except the code used for the switchboard:

Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM [Switchboard Items]"
stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" &
Me![SwitchboardID]
stSql = stSql & " ORDER BY [ItemNumber];"
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard
page"
Else
While (Not (rs.EOF))
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If

' Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing

End Sub

The error occurs on the line Set con = Application.CurrentProject.Connection

The error dialogue box says: Run-time error '-2147024769 (8007007f)': Method
'connection' of object '_CurrentProject' failed


Any ideas???
 
D

Dave F

When I click on the link at that page, I'm told it no longer exists, and I'm
redirected here:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/dataaccess.asp

I'm assuming the link I'm interested in is MDAC 2.8...but when I click
through there I don't know what component/update I should download....any
ideas?

jmonty said:
Take a look at this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;306132&Product=acc


jmonty


Dave F said:
A colleague created a db using access 2003 but saved it in access 2000
format, since most access installations here use Access 2000.

Everything seems to work fine except the code used for the switchboard:

Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM [Switchboard Items]"
stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" &
Me![SwitchboardID]
stSql = stSql & " ORDER BY [ItemNumber];"
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard
page"
Else
While (Not (rs.EOF))
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If

' Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing

End Sub

The error occurs on the line Set con = Application.CurrentProject.Connection

The error dialogue box says: Run-time error '-2147024769 (8007007f)': Method
'connection' of object '_CurrentProject' failed


Any ideas???
 
J

jmonty

I have no problems with the link. I am not sure why you are.
Any way I will attempt to paste into this thread:

You receive a "Method 'Connection' of Object '_currentproject' Failed" error
message
View products that this article applies to.
Article ID : 306132
Last Review : August 10, 2004
Revision : 1.0
This article was previously published under Q306132
Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).


SYMPTOMS
When you attempt to use a wizard or to open a switchboard in Access 2000,
you receive the following error message:
Method 'connection' of object '_currentproject' failed.
Back to the top

CAUSE
This behavior can result from a damaged or a corrupted Microsoft Data Access
Components (MDAC) stack.
Back to the top

RESOLUTION
To resolve this behavior, download and install the latest version of MDAC
from the following Microsoft Web site:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/dataaccess.asp
(http://msdn.microsoft.com/library/default.asp?url=/downloads/list/dataaccess.asp)
This site also provides links to information about how to install MDAC.
Back to the top

MORE INFORMATION
You see this behavior most commonly with a switchboard form, the Lookup
wizard, the Combo Box wizard, or the List Box wizard. However, this behavior
can also occur with other wizards or builders.
Back to the top


--------------------------------------------------------------------------------

APPLIES TO
• Microsoft Access 2000 Standard Edition
• Microsoft Access 2002 Standard Edition

Back to the top

Keywords: kberrmsg kbprb KB306132


jmonty


Dave F said:
When I click on the link at that page, I'm told it no longer exists, and I'm
redirected here:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/dataaccess.asp

I'm assuming the link I'm interested in is MDAC 2.8...but when I click
through there I don't know what component/update I should download....any
ideas?

jmonty said:
Take a look at this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;306132&Product=acc


jmonty


Dave F said:
A colleague created a db using access 2003 but saved it in access 2000
format, since most access installations here use Access 2000.

Everything seems to work fine except the code used for the switchboard:

Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM [Switchboard Items]"
stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" &
Me![SwitchboardID]
stSql = stSql & " ORDER BY [ItemNumber];"
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard
page"
Else
While (Not (rs.EOF))
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If

' Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing

End Sub

The error occurs on the line Set con = Application.CurrentProject.Connection

The error dialogue box says: Run-time error '-2147024769 (8007007f)': Method
'connection' of object '_CurrentProject' failed


Any ideas???
 

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