Error 3015

durdle

Registered User.
Local time
Today, 19:54
Joined
May 7, 2002
Messages
130
Hey,

I am getting an error message for an udate button I have programmed. The error reads

'Primary Key' isn't an index in this table. Look in the indexes collection of the TableDef object to determine the valid index names.

I have the primary key set on both tables but I am not sure why this is happening.
Any suggestions would be great!

Chris

Private Sub Command20_Click()

Dim rsupdate As Recordset
Dim dbmain As Database

Set dbmain = CurrentDb()
Set rsupdate = dbmain.OpenRecordset("tbltest")

Dim Jobno As String
txtJobNo.SetFocus
Jobno = txtJobNo.Text

'I get the error on the next line

rsupdate.Index = "Primary Key"
rsupdate.Seek "=", txtJobNo.Text

If rsupdate.NoMatch Then
MsgBox " Test"

End If

End Sub
________
ford n series tractors history
 
Last edited:
How about:
Private Sub Command20_Click()

Dim rsupdate As Recordset
Dim dbmain As Database

Set dbmain = CurrentDb()
Set rsupdate = dbmain.OpenRecordset("tbltest")

rsupdate.Index = "PrimaryKey"
rsupdate.Seek "=", txtJobNo

If rsupdate.NoMatch Then
MsgBox " Test"

End If

End Sub

I removed the extraneous code. There is no need to set focus to the control if you don't refer to its text property. Better technique is to use the control's value property which is the default. I also removed the variable since you were not using it except to set it.
 

Users who are viewing this thread

Back
Top Bottom