473,412 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Error with switchboard code

Please help, i'm baffled.

I have opened my db and recieved an error on this code which starts the
switchboard. As i didn't write this code i'm baffled, and I don't think
I have made any changes to it.

' 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

It is a problem with the Set con line.

Any ideas on how I can fix this or what the problem may be?

Jan 18 '07 #1
6 6428
This code has been 'made to work' by referring to the ADO database library
as an object:
Set rs = CreateObject("ADODB.Recordset")
While it is possible to do this, it is not the normal practice.

In that module (or any other), go to the menu Tools\References. In the list
of Available Resources, find Microsoft ActiveX Data Objects 2.? Library,
where the ? is the highest version number, and check that.

There is or should be a first line to your code that says,

Dim con As Object

You can now safely delete that, and the next line with the Set statement.

Change this line:
rs.Open stSql, con, 1 ' 1 = adOpenKeyset
To:
rs.Open stSql, CurrentProject.Connection, 1 ' 1 = adOpenKeyset

This will fix the immediate problem, however, once you get past the
switchboard, you may encounter many more problems if this is an example of
how the rest of the code was written.

Suggest you read up on CreateObject and References in the Access help.
--
Darryl Kerkeslager
"keri" <ke*********@diageo.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Please help, i'm baffled.

I have opened my db and recieved an error on this code which starts the
switchboard. As i didn't write this code i'm baffled, and I don't think
I have made any changes to it.

' 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

It is a problem with the Set con line.

Any ideas on how I can fix this or what the problem may be?

Jan 18 '07 #2
I am going to read what you have suggested.

I followed your steps and now recieve this error on starting the
database or when trying to run the switchboard form.

The expression On Open you enetered as the event property setting
produced the following error;
Error in loading DLL

Jan 18 '07 #3
The debug function highlights the connection part of this code;
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
rs.Open stSql, CurrentProject.Connection, 1 ' 1 = adOpenKeyset

I'd appreciate any suggestions as this is being presented tomorrow!

Jan 18 '07 #4
Dim rs As ADODB.Recordset
Dim stSql As String

stSql = "SELECT * FROM [Switchboard Items]"
stSql = stSql & " WHERE [ItemNumber] 0 AND [SwitchboardID]=" &
Me![SwitchboardID]
stSql = stSql & " ORDER BY [ItemNumber];"
rs.Open stSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic,
adCmdText

--
Darryl Kerkeslager
Jan 19 '07 #5
"keri" <ke*********@diageo.comwrote in message
<11**********************@38g2000cwa.googlegroups. com>:
Please help, i'm baffled.

I have opened my db and recieved an error on this code which starts
the switchboard. As i didn't write this code i'm baffled, and I don't
think I have made any changes to it.

' 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

It is a problem with the Set con line.

Any ideas on how I can fix this or what the problem may be?
I think this is an MDAC issue. Try to update/reinstall your MDAC -
watch for linebreaks in the links

http://support.microsoft.com/default...32&Product=acc
http://msdn.microsoft.com/library/de...dataaccess.asp

If this doesn't work, here's another thread where it didn't (now,
that's a comfort, eh? <g>)

http://groups.google.com/group/micro...d794bb3595943/

And the solition found by the OP presented here
http://groups.google.com/group/micro...cf7c9fd54454e9

--
Roy-Vidar
Jan 19 '07 #6
Roy - thanks for the best link that has ever been posted on this group.
I've followed the solution on the link and (fingers crossed) so far so
good as everything seems to be working.

Thanks!

Jan 21 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dannic | last post by:
Here is the application. Its a simple application really. I have a db created in Access 2000 which opens to a switchboard created by the switchboard manager. Now the problem. This only works...
2
by: Dejan M. | last post by:
Can you help me? I have 9 forms in the base. 2 forms are opening as single and 7 as datasheet. Thats OK, but when I used Switchboard manager, with him all of my forms are opened as single. How can...
7
by: aaaaaa | last post by:
Hi, I created some forms and during the wizard I chose the Datasheet View, and when I open the forms from the main objects window they open up in datasheet view. But when I created a switchboard...
5
by: Michael Keene | last post by:
I have a query that I'd like to add to my switchboard, but when I use the switchboard manager I only get the option to run a report, a macro or open a form. Is there a way to add a query without...
2
by: Neil Greenough | last post by:
I am trying to create a Switchboard using the Switchboard Manager in MS Access 2000. I have managed to get the table created for the switchboard, however it hasn't actually created the form. ...
1
by: mplus_2000 | last post by:
I have recently inherited a database. The switchboard (and other forms) displays the name of the database on it (top, center). Currently the name that appears is Reviews. There are plans to roll...
2
by: Miguel | last post by:
I have reviewed the many postings on this topic and understand the principle, but am not sure where in my case to apply trapping an error. I have created a form to supply parameters to a report. I...
13
by: jsmith811 | last post by:
I setup a very simple database for a client, it has only one table. I have startup options set to open straight to the Switchboard, so users only see the Switchboard menu. The database has 3...
5
by: bluesokie | last post by:
I have developed a Microsoft Access 2003 database that opens a switchboard. On one computer it opens with no problem. On two others I receive the following error: "Method 'Connection' of object...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.