After Update Question

G

Guest

I am using a bound combo box with the Limit to List property turned off. What
I am trying to do is check to see if the user picks a value from the list,
and if he does, set the values of other controls in the form with values from
the table that the combo box is bound to (different fields). I'm trying to
use the After Update event to do this, by searching for the value in the
table using findfirst, and then an if clause based on the NoMatch property. I
keep getting an error that says "Procedure declaration does not match
description of event or procedure having the same name." Below is the code I
have so far (I haven't gotten so far as to update the other values, b/c I
keep getting this error just based on the "find" part):

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset
Dim strFind as String
Dim StrMessage As String

Set rs = CurrentDb.OpenRecordset("AOIs")
Set strFind = "NAME = '" & NewData & "'"

With rs
varBookmark = .Bookmark
.FindFirst strFind

If .NoMatch Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If
End With

End Sub
 
G

Guest

Try this

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset, MyDB as Dao.DataBase
Dim strFind as String
Dim StrMessage As String
Set MyDB = currentdb()
' will work faster that way, the find first after openning the whole table
can take a while
Set rs = MyDB.OpenRecordset("Select * From AOIs Where [NAME] = '" & NewData
& "'")
If rs.eof Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If

End Sub

NAME is key word in Access and it's not recomanded using it as a field name
 
G

Guest

Thanks for the tip....I'm still getting the same error message:
The expression After Update you entered as the event property setting
produced the following error: Procedure declaration does not match
description of event or procedure having the same name.

*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.

Ever seen this before? Know what it means? I'm pulling my hair out here:).

Ofer Cohen said:
Try this

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset, MyDB as Dao.DataBase
Dim strFind as String
Dim StrMessage As String
Set MyDB = currentdb()
' will work faster that way, the find first after openning the whole table
can take a while
Set rs = MyDB.OpenRecordset("Select * From AOIs Where [NAME] = '" & NewData
& "'")
If rs.eof Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If

End Sub

NAME is key word in Access and it's not recomanded using it as a field name
--
Good Luck
BS"D


marshunc said:
I am using a bound combo box with the Limit to List property turned off. What
I am trying to do is check to see if the user picks a value from the list,
and if he does, set the values of other controls in the form with values from
the table that the combo box is bound to (different fields). I'm trying to
use the After Update event to do this, by searching for the value in the
table using findfirst, and then an if clause based on the NoMatch property. I
keep getting an error that says "Procedure declaration does not match
description of event or procedure having the same name." Below is the code I
have so far (I haven't gotten so far as to update the other values, b/c I
keep getting this error just based on the "find" part):

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset
Dim strFind as String
Dim StrMessage As String

Set rs = CurrentDb.OpenRecordset("AOIs")
Set strFind = "NAME = '" & NewData & "'"

With rs
varBookmark = .Bookmark
.FindFirst strFind

If .NoMatch Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If
End With

End Sub
 
G

Guest

Try removing the parameter from the procedure.

Instead of:

Private Sub Combo82_AfterUpdate(NewData As String)

Use:

Private Sub Combo82_AfterUpdate().

If you need to refer to the valure in the procedure, you can use me.combo82
to get it.

Jim B.

marshunc said:
Thanks for the tip....I'm still getting the same error message:
The expression After Update you entered as the event property setting
produced the following error: Procedure declaration does not match
description of event or procedure having the same name.

*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.

Ever seen this before? Know what it means? I'm pulling my hair out here:).

Ofer Cohen said:
Try this

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset, MyDB as Dao.DataBase
Dim strFind as String
Dim StrMessage As String
Set MyDB = currentdb()
' will work faster that way, the find first after openning the whole table
can take a while
Set rs = MyDB.OpenRecordset("Select * From AOIs Where [NAME] = '" & NewData
& "'")
If rs.eof Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If

End Sub

NAME is key word in Access and it's not recomanded using it as a field name
--
Good Luck
BS"D


marshunc said:
I am using a bound combo box with the Limit to List property turned off. What
I am trying to do is check to see if the user picks a value from the list,
and if he does, set the values of other controls in the form with values from
the table that the combo box is bound to (different fields). I'm trying to
use the After Update event to do this, by searching for the value in the
table using findfirst, and then an if clause based on the NoMatch property. I
keep getting an error that says "Procedure declaration does not match
description of event or procedure having the same name." Below is the code I
have so far (I haven't gotten so far as to update the other values, b/c I
keep getting this error just based on the "find" part):

Private Sub Combo82_AfterUpdate(NewData As String)

Dim rs As DAO.Recordset
Dim strFind as String
Dim StrMessage As String

Set rs = CurrentDb.OpenRecordset("AOIs")
Set strFind = "NAME = '" & NewData & "'"

With rs
varBookmark = .Bookmark
.FindFirst strFind

If .NoMatch Then
strMessage = "No Match Found"
MsgBox strMessage

Else
strMessage = "Match Found"
MsgBox strMessage
End If
End With

End Sub
 

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