A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access/VB code error



 
 
Thread Tools Display Modes
  #1  
Old September 5th, 2004, 10:33 AM
external usenet poster
 
Posts: n/a
Default Access/VB code error

Help would be greatly appreciated with the following.

I have created a database with a form and tables. On the
form I have created a test button. The code below
(fragment)is from an example in access (Index Property).
I have pasted this code on my form's code part and the
procedure Seek() is used in my test button procedure.

The problem is that I can't get the Seek() procedure to
work. The following error occurs..
Run-time error '-2147217867 (80040e35)'
EmployeeID is not an index in this table

This database does exist in the given directory. The
employees table does exist and employeeID is a field of
this table with the "key" symbol to the extreme left of
the screen.

How do I interpret the error and where have I gone wrong.



Public Sub SeekX()
Dim rst As ADODB.Recordset
Dim strID As String
Dim strPrompt As String
strPrompt = "Enter an EmployeeID (e.g., 1 to 9)"

Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open "employees", _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Microsoft
Office\Office\Samples\northwind.mdb;" & _
"user id=admin;password=;", _
adOpenKeyset, adLockReadOnly,
adCmdTableDirect
' "Data Source=c:\temp\northwind.mdb;" & _
' Does this provider support Seek and Index?
If rst.Supports(adIndex) And rst.Supports(adSeek) Then
rst.Index = "EmployeeID" ******** This is where the
error occurs *************
' Display all the employees.

  #2  
Old September 5th, 2004, 11:53 AM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

You need to use the name of the index, not the name of the field in the
index

If the key symbol is beside EmployeeId, odds are the Index name is
PrimaryKey. To double check, open the table in Design mode, and select View
| Indexes from the menu bar. The Index Name will be in the left-most column
of the display.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



wrote in message
...
Help would be greatly appreciated with the following.

I have created a database with a form and tables. On the
form I have created a test button. The code below
(fragment)is from an example in access (Index Property).
I have pasted this code on my form's code part and the
procedure Seek() is used in my test button procedure.

The problem is that I can't get the Seek() procedure to
work. The following error occurs..
Run-time error '-2147217867 (80040e35)'
EmployeeID is not an index in this table

This database does exist in the given directory. The
employees table does exist and employeeID is a field of
this table with the "key" symbol to the extreme left of
the screen.

How do I interpret the error and where have I gone wrong.



Public Sub SeekX()
Dim rst As ADODB.Recordset
Dim strID As String
Dim strPrompt As String
strPrompt = "Enter an EmployeeID (e.g., 1 to 9)"

Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open "employees", _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Microsoft
Office\Office\Samples\northwind.mdb;" & _
"user id=admin;password=;", _
adOpenKeyset, adLockReadOnly,
adCmdTableDirect
' "Data Source=c:\temp\northwind.mdb;" & _
' Does this provider support Seek and Index?
If rst.Supports(adIndex) And rst.Supports(adSeek) Then
rst.Index = "EmployeeID" ******** This is where the
error occurs *************
' Display all the employees.



  #3  
Old September 5th, 2004, 12:57 PM
external usenet poster
 
Posts: n/a
Default


Thanks for that, it worked. The example used was that
from the aaccess help. So was there an error in the
coding by MS?
I can now be on my way to discover new stuff. Thanks again
  #4  
Old September 5th, 2004, 01:27 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

wrote in message
...

Thanks for that, it worked. The example used was that
from the aaccess help. So was there an error in the
coding by MS?


Not necessarily. Indexes can be named whatever you like. If you already had
an index named PrimaryKey and you added a new index based on the EmployeeId,
you may very well choose to name that new index EmployeeId.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to RTF very slow when code is present in Access report. [email protected] Setting Up & Running Reports 11 September 14th, 2004 08:17 PM
Troubleshoot the SendObject method Nikky_Pickles General Discussion 1 August 30th, 2004 07:40 AM
Problem with err.raise Bogdan Zamfir New Users 4 July 31st, 2004 07:54 PM
Continual Error 1321 Trying to Install Office 2003 Chad Harris General Discussions 9 June 11th, 2004 08:19 AM


All times are GMT +1. The time now is 12:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.