Error

A

Asif

Hello

I have a suppliers form which I have a button which
relates to the following code

Private Sub cmdFindSupplier_Click()

Dim rst As ADODB.Recordset
Dim strCriteria As String

strCriteria = "[ContactName] Like '*" & InputBox
("Enter the " _
& "first few letters of the name to find") & "*'"

Set rst = Me.RecordsetClone
rst.Find strCriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

When I click on the button it comes with the following
error and the If rst.NoMatch Then is highlighted
Compile Error:
Method or data member not found.

I think the error comes because it relates to a DAO
reference, but I am using an adp with ADODB reference.
What can I use instead on NoMatch that relates to that
reference?.

Kind Regards
Asif
 
J

John Crighton

Asif,

Try using "Dim rst As New ADODB.Recordset" <-- i.e.
put "new" in there.

HTH

John.
 
A

Asif

Hello

Thanks for that John unfortunatley it still comes up with
the same error.

Kind Regards
Asif
-----Original Message-----
Asif,

Try using "Dim rst As New ADODB.Recordset" <-- i.e.
put "new" in there.

HTH

John.
-----Original Message-----
Hello

I have a suppliers form which I have a button which
relates to the following code

Private Sub cmdFindSupplier_Click()

Dim rst As ADODB.Recordset
Dim strCriteria As String

strCriteria = "[ContactName] Like '*" & InputBox
("Enter the " _
& "first few letters of the name to find") & "*'"

Set rst = Me.RecordsetClone
rst.Find strCriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

When I click on the button it comes with the following
error and the If rst.NoMatch Then is highlighted
Compile Error:
Method or data member not found.

I think the error comes because it relates to a DAO
reference, but I am using an adp with ADODB reference.
What can I use instead on NoMatch that relates to that
reference?.

Kind Regards
Asif
.
.
 
J

John Crighton

Asif,

You may need to check for EOF/BOF?

If that's not the problem then I'd look at the criteria,
as the rest of your code looks ok...

John C
-----Original Message-----
Hello

Thanks for that John unfortunatley it still comes up with
the same error.

Kind Regards
Asif
-----Original Message-----
Asif,

Try using "Dim rst As New ADODB.Recordset" <-- i.e.
put "new" in there.

HTH

John.
-----Original Message-----
Hello

I have a suppliers form which I have a button which
relates to the following code

Private Sub cmdFindSupplier_Click()

Dim rst As ADODB.Recordset
Dim strCriteria As String

strCriteria = "[ContactName] Like '*" & InputBox
("Enter the " _
& "first few letters of the name to find") & "*'"

Set rst = Me.RecordsetClone
rst.Find strCriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

When I click on the button it comes with the following
error and the If rst.NoMatch Then is highlighted
Compile Error:
Method or data member not found.

I think the error comes because it relates to a DAO
reference, but I am using an adp with ADODB reference.
What can I use instead on NoMatch that relates to that
reference?.

Kind Regards
Asif
.
.
.
 
J

John Crighton

Asif,

You need to use rst.EOF and rst.BOF (end of
file/beggining of file) to see if there are actually any
records in rst.

I think you're likely to get this error if there are none.

In which case you might need to look at your criteria too.

HTH

John C

-----Original Message-----
Hi John

Sorry what do you mean EOF/BOF?

regards
Asif
-----Original Message-----
Asif,

You may need to check for EOF/BOF?

If that's not the problem then I'd look at the criteria,
as the rest of your code looks ok...

John C
-----Original Message-----
Hello

Thanks for that John unfortunatley it still comes up with
the same error.

Kind Regards
Asif
-----Original Message-----
Asif,

Try using "Dim rst As New ADODB.Recordset" <-- i.e.
put "new" in there.

HTH

John.

-----Original Message-----
Hello

I have a suppliers form which I have a button which
relates to the following code

Private Sub cmdFindSupplier_Click()

Dim rst As ADODB.Recordset
Dim strCriteria As String

strCriteria = "[ContactName] Like '*" & InputBox
("Enter the " _
& "first few letters of the name to find") & "*'"

Set rst = Me.RecordsetClone
rst.Find strCriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

When I click on the button it comes with the following
error and the If rst.NoMatch Then is highlighted
Compile Error:
Method or data member not found.

I think the error comes because it relates to a DAO
reference, but I am using an adp with ADODB reference.
What can I use instead on NoMatch that relates to that
reference?.

Kind Regards
Asif
.

.

.
.
.
 

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