run time error 429

G

Guest

Im new Access user and I don't understand where I mistaken. Following are
sample from textbook:

Private Sub EesnimeKast_BeforeUpdate(Cancel As Integer)
Dim k As Recordset


If IsNull(PerekonnanimeKast) Then Exit Sub
If IsNull(EesnimeKast) Then
Cansel = True
End If

Set k = CurrentDb.OpenRecordset( _
"SELECT * FROM Kliendid WHERE Perekonnanimi='" & PerekonnanimeKast & _
"' AND Eesnimi='" & EesnimeKast & "'")

If k.RecordCount = 0 Then
Cansel = True
Exit Sub
Else
k.MoveLast
End If

If k.RecordCount > 1 Then
MsgBox "Valitud ole üheselt määratud!", _
vbCritical, "Müügiandmete vaatlemine"

Exit Sub


The line of code which generates the error
message is:

Set k = CurrentDb.OpenRecordset( _
"SELECT * FROM Kliendid WHERE Perekonnanimi='" & PerekonnanimeKast & _
"' AND Eesnimi='" & EesnimeKast & "'")

What is wrongly
Thanks for any ideas
 
M

Marshall Barton

Jaan said:
Im new Access user and I don't understand where I mistaken. Following are
sample from textbook:

Private Sub EesnimeKast_BeforeUpdate(Cancel As Integer)
Dim k As Recordset


If IsNull(PerekonnanimeKast) Then Exit Sub
If IsNull(EesnimeKast) Then
Cansel = True
End If

Set k = CurrentDb.OpenRecordset( _
"SELECT * FROM Kliendid WHERE Perekonnanimi='" & PerekonnanimeKast & _
"' AND Eesnimi='" & EesnimeKast & "'")

If k.RecordCount = 0 Then
Cansel = True
Exit Sub
Else
k.MoveLast
End If

If k.RecordCount > 1 Then
MsgBox "Valitud ole üheselt määratud!", _
vbCritical, "Müügiandmete vaatlemine"

Exit Sub


The line of code which generates the error
message is:

Set k = CurrentDb.OpenRecordset( _
"SELECT * FROM Kliendid WHERE Perekonnanimi='" & PerekonnanimeKast & _
"' AND Eesnimi='" & EesnimeKast & "'")


What data type are the Perekonnanimi and Eesnimi fields? If
a field is a numeric type then you should not use ' around
the value.
 
G

Guest

Hi
Both are text type.

The Sample is wrote by Access 97. I use Access 2000. Is there are
differentses.



"Marshall Barton" kirjutas:
 
M

Marshall Barton

The big difference is that A2k has ADO as the default data
library, while A97 had DAO as the default library. Check
your library references (Tools menu in VBE window). If you
didn't intend to use ADO, uncheck that reference and check
DAO. If you are using both, then you should disambiguate
the conflicting declarations. E.g.

Dim k As DAO.Recordset
 
G

Guest

Hi March

I coped herewith. Thanks for consulting.

Jaan



"Marshall Barton" kirjutas:
The big difference is that A2k has ADO as the default data
library, while A97 had DAO as the default library. Check
your library references (Tools menu in VBE window). If you
didn't intend to use ADO, uncheck that reference and check
DAO. If you are using both, then you should disambiguate
the conflicting declarations. E.g.

Dim k As DAO.Recordset
--
Marsh
MVP [MS Access]

Both are text type.

The Sample is wrote by Access 97. I use Access 2000. Is there are
differentses.



"Marshall Barton" kirjutas:
 

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