Compile Error: Method or data member not found...

Mike Vytal

Registered User.
Local time
Today, 10:32
Joined
Feb 1, 2007
Messages
34
The highlighted line is where the problem lies. I've made sure MS DAO 3.6 object library, VB for Apps, MS Access 9.0 library, OLE automation, and MS Data ActiveX Data Objects 2.1 Library under Tools---->References are all selected. What am I missing or doing wrong? Thanx in advance for your help.

If Not IsNull(Me.txtLastName) And Not IsNull(Me.txtFirstName) Then
strContact = Me.txtLastName & Me.txtFirstName
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Participants", 2)
rst.Find "[LastName] & [FirstName] Like '*" & strContact & "*'"
With rst
If rst.NoMatch Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
If MsgBox("A " & !FirstName & " " & !LastName & " already exists. Continue update?", 260) = vbYes Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
Cancel = True
Me.Undo
.Close
End If
End If
End With
End If
 
Thanx for the response. I tried the NoMatch without the "." and it seemed to work...I will let you know for sure soon. Meanwhile, what's wrong with the following code (redlined where the problem lies) When you mouseover rst, it says rst=Nothing.

Private Sub txtLastName_AfterUpdate()

If Not IsNull(Me.txtLastName) And Not IsNull(Me.txtFirstName) Then
strContact = Me.txtLastName & " " & Me.txtFirstName
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Participants", dbOpenDynaset)
rst.Find "[LastName] & [FirstName] Like '*" & strContact & "*'"
With rst
If NoMatch Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
If MsgBox("A " & !FirstName & " " & !LastName & " already exists. Continue update?", 260) = vbYes Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
Cancel = True
Me.Undo
.Close
End If
End If
End With
End If

Exit_txtFirstName_BeforeUpdate:
Set dbs = Nothing



End Sub
 
it probably WILL be nothing until AFTER you have executed the assignment.

now, i thought it was .nomatch (ie a method of recordsets), not just NOMATCH

so there is something strange
a) do you get a compiler error
b) in your module at the top does it say
option explicit
if not then nomatch is being instantiated as a variable, and your code isnt doing what it should. if it is, then you should get a compiler error

i dont think you can phrase a search like this as you have done
rst.Find "[LastName] & [FirstName] Like '*" & strContact & "*'"

loooking at your code, you are not doing anything with the recordset are you, other than a search so a simple

dlookup("whatever","tblparticipants","whereclause") would suffice

but the where clause would be similar to your findfirst clause, which is not correct

sorry, but i dont think this is correct, and i think you need to have another look at this
 
I have the code below on both unbound fields (txtLastName & txtFirstName) on the after update event. It works when I enter the first name first, then last name. Gemma, at the top it says Option Compare Database, but I did include the "." with NoMatch, and I don't get the error with it anymore. What I'd like to do now is pull up a list box of all the matches and have the user be able to select the match, hit a yes button (or double click if possible), and go directly to that record. Any & all help is greatly appreciated. I'm getting there!!! :cool:

Private Sub txtLastName_AfterUpdate()

If Not IsNull(Me.txtLastName) And Not IsNull(Me.txtFirstName) Then
strContact = Me.txtLastName & Me.txtFirstName
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Participants", 2)
rst.FindFirst "[LastName] & [FirstName] Like '*" & strContact & "*'"
With rst
If .NoMatch Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
If MsgBox("A " & !FirstName & " " & !LastName & " already exists. Continue update?", 260) = vbYes Then
.Close
GoTo Exit_txtFirstName_BeforeUpdate
Else
Cancel = True
Me.Undo
.Close
End If
End If
End With
End If

Exit_txtFirstName_BeforeUpdate:
Set dbs = Nothing


End Sub
 
Simple Software Solutions

I answered your question on your earlier thread regarding duplicate finds.
 
seriously, you should have option explicit at the top

if you dont variables will be created "on the fly"as it were, so mistyping will create spurious side effects

eg in your case you should have rst.nomatch, ot just .nomatch

because you do not have option explicit, using an expression

nomatch, will create a variant called nomatch, which is not at all what you want,since it will always be false

-------
with regard to the popup, you need to write a query that finds all the duplicates, and open a form based on that query. then you can get the functionality you want. I am still not convinced that your findfirst clause will work properly however
 

Users who are viewing this thread

Back
Top Bottom