find button - missing code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
sorry here's the text
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Su
---------------------------------------------------------------------------------------
 
Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

Ofer said:
Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
 
Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

Ofer said:
Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
hi again,
within the form i have additional buttons, thus more code. at the top i have
"Option Compare Database"...

Private Sub btnSearchSurname_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "CUSTOMER_SURNAME = '" & searchvalue & "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub

thanks


Ofer said:
Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

Ofer said:
Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
While in code, go to tools > reference in the menu bar, and select from the
list DAO 3.6
Then change the decleration to
Dim mytable As DAO.Recordset
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
hi again,
within the form i have additional buttons, thus more code. at the top i have
"Option Compare Database"...

Private Sub btnSearchSurname_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "CUSTOMER_SURNAME = '" & searchvalue & "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub

thanks


Ofer said:
Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

:

Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
thanks ofer, i've now added the reference and it works fine.

the only issue now is that the wildcard "*" doesn't work on partial surname
search.
somehow it did work on the previous code.
can this option be available on the current code?

Ofer said:
While in code, go to tools > reference in the menu bar, and select from the
list DAO 3.6
Then change the decleration to
Dim mytable As DAO.Recordset
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
hi again,
within the form i have additional buttons, thus more code. at the top i have
"Option Compare Database"...

Private Sub btnSearchSurname_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "CUSTOMER_SURNAME = '" & searchvalue & "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub

thanks


Ofer said:
Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

:

Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
Try this for the wild card

Criteria = "CUSTOMER_SURNAME Like *" & searchvalue & "*"

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
thanks ofer, i've now added the reference and it works fine.

the only issue now is that the wildcard "*" doesn't work on partial surname
search.
somehow it did work on the previous code.
can this option be available on the current code?

Ofer said:
While in code, go to tools > reference in the menu bar, and select from the
list DAO 3.6
Then change the decleration to
Dim mytable As DAO.Recordset
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
hi again,
within the form i have additional buttons, thus more code. at the top i have
"Option Compare Database"...

Private Sub btnSearchSurname_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "CUSTOMER_SURNAME = '" & searchvalue & "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub

thanks


:

Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

:

Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
great.thanks very much and bye for now

Ofer said:
Try this for the wild card

Criteria = "CUSTOMER_SURNAME Like *" & searchvalue & "*"

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



luzippu said:
thanks ofer, i've now added the reference and it works fine.

the only issue now is that the wildcard "*" doesn't work on partial surname
search.
somehow it did work on the previous code.
can this option be available on the current code?

Ofer said:
While in code, go to tools > reference in the menu bar, and select from the
list DAO 3.6
Then change the decleration to
Dim mytable As DAO.Recordset
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

hi again,
within the form i have additional buttons, thus more code. at the top i have
"Option Compare Database"...

Private Sub btnSearchSurname_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "CUSTOMER_SURNAME = '" & searchvalue & "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub

thanks


:

Have you changed that "[CUSTOMER_SURNAME field name in the table] to the name
of the field in your table?
If yes, can you post your code
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

I've copied the code on the button's event procedure, but when clicked I get
"method or data member not found" on '.FirstFind'

I've noticed that the dropdown list for 'mytable.' doesn not include
'.NoMatch' either.

have I missed anything??
thanks again

:

Try this, using bookmark
Private Sub Search_Click()
Dim mytable As Recordset
Dim Criteria As String
Dim FormMark
Dim searchvalue As String
searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

Criteria = "[CUSTOMER_SURNAME field name in the table] = '" & searchvalue
& "'"
Set mytable = Me.RecordsetClone
mytable.FindFirst Criteria
If mytable.NoMatch Then
MsgBox "No Match"
Else
FormMark = mytable.Bookmark
Me.Bookmark = FormMark
Me.txt_CUSTOMER_SURNAME.SetFocus
End If
End Sub
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

sorry here's the text:
------------------------------------------------------------------------------------
Private Sub btnSearchSurname_Click()
Dim searchvalue As String

searchvalue = InputBox("Enter Customer Surname", "Select Surname")
If searchvalue = "" Then
Exit Sub
End If

txt_CUSTOMER_SURNAME.SetFocus
DoCmd.FindRecord (searchvalue)

End Sub
---------------------------------------------------------------------------------------

:

There is no code, can you post it please?
--
I hope that helped
Good luck


:

hi

the following is the code behind a button on a customer single form that
search records through customer surname. (access 2002)

It works, but needs a few extra lines:

- msgbox when no record found (i've tried to use .nomatch and .eof but no
luck!?)
- if there are 2 mr smith on the datasource, the code finds the first one,
but if performed again it will not go to the next record.

can you help in modifying the code on this.

thank you
 
Back
Top