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?