|
 |
access thread: How to add search command inside the ACCESS 2000
Message #1 by "Raingo" <raingo@h...> on Wed, 25 Jul 2001 11:56:42 +0800
|
|
Hi, all,
I'm a beginner, with my homework, i want to add a command button
such as search command, it can be automatic find out matched record and
goto display this matched record at same page. But when i write a VBA
script, it is no success, Could you help me to modify it? Thank you so
much.
Thanks all of lots!
Raingo
VBA Script:
Option Compare Database
Option Explicit
Private mFlg As Boolean
Private Sub Form_Load()
mFlg =3D False
End Sub
Private Sub Search_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim criteria As String
Set db =3D CurrentDb()
Set rs =3D Me.Recordset.Clone
rs.Bookmark =3D Me.Bookmark
criteria =3D "Device LLI Like '*" & Me!txt & "*'"
If mFlg =3D False Then
rs.FindFirst criteria
mFlg =3D True
Else
rs.FindNext criteria
End If
If rs.NoMatch Then
MsgBox ("No have matched recordes !")
Else
Me.Bookmark =3D rs.Bookmark
End If
rs.Close: Set rs =3D Nothing
End Sub
Private Sub txt_AfterUpdate()
mFlg =3D False
End Sub
Where "Device LLI" is Text, no case in sensetive
And if you want to my ACCESS mdb, send a mail let me know. Because
there are no accept attachment.
Message #2 by "Yehuda Rosenblum" <Yehuda@I...> on Wed, 25 Jul 2001 08:57:14 -0400
|
|
Post a copy of the code and please tell us the error you are getting.
-----Original Message-----
From: Raingo [mailto:raingo@h...]
Sent: Tuesday, July 24, 2001 11:57 PM
To: Access
Subject: [access] How to add search command inside the ACCESS 2000
Hi, all,
I'm a beginner, with my homework, i want to add a command button
such as search command, it can be automatic find out matched record and
goto display this matched record at same page. But when i write a VBA
script, it is no success, Could you help me to modify it? Thank you so
much.
Thanks all of lots!
Raingo
VBA Script:
Option Compare Database
Option Explicit
Private mFlg As Boolean
Private Sub Form_Load()
mFlg =3D False
End Sub
Private Sub Search_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim criteria As String
Set db =3D CurrentDb()
Set rs =3D Me.Recordset.Clone
rs.Bookmark =3D Me.Bookmark
criteria =3D "Device LLI Like '*" & Me!txt & "*'"
If mFlg =3D False Then
rs.FindFirst criteria
mFlg =3D True
Else
rs.FindNext criteria
End If
If rs.NoMatch Then
MsgBox ("No have matched recordes !")
Else
Me.Bookmark =3D rs.Bookmark
End If
rs.Close: Set rs =3D Nothing
End Sub
Private Sub txt_AfterUpdate()
mFlg =3D False
End Sub
Where "Device LLI" is Text, no case in sensetive
And if you want to my ACCESS mdb, send a mail let me know. Because
there are no accept attachment.
---
Message #3 by Miriam Engelberg <MiriamE@c...> on Wed, 25 Jul 2001 15:25:08 -0700
|
|
I'd suggest using the automated wizard to add a search combo box. If you are
interested in doing your own in future, you can look at the code inserted by
the wizard to learn how it works. To use the wizard, go into design view of
the form, make sure the Toolbox is visible (the toolbar with form design
buttons), click on the Combo Box button, then click in the form. Choose the
3rd option, which says something like: Find a record on my form based on the
value I selected in my combo box. (If the wizard doesn't start up, make sure
the Wizards button is pressed in on the toolbox.) Send over the ID field
first, and then any other fields you wish to see in the box (Last name,
first name, etc.). Leave the ID field hidden, as the wizard recommends.
Hope this helps!
Miriam
-----Original Message-----
From: Raingo [mailto:raingo@h...]
Sent: Tuesday, July 24, 2001 8:57 PM
To: Access
Subject: [access] How to add search command inside the ACCESS 2000
Hi, all,
I'm a beginner, with my homework, i want to add a command button such as
search command, it can be automatic find out matched record and goto display
this matched record at same page. But when i write a VBA script, it is no
success, Could you help me to modify it? Thank you so much.
Thanks all of lots!
Raingo
VBA Script:
Option Compare Database
Option Explicit
Private mFlg As Boolean
Private Sub Form_Load()
mFlg = False
End Sub
Private Sub Search_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim criteria As String
Set db = CurrentDb()
Set rs = Me.Recordset.Clone
rs.Bookmark = Me.Bookmark
criteria = "Device LLI Like '*" & Me!txt & "*'"
If mFlg = False Then
rs.FindFirst criteria
mFlg = True
Else
rs.FindNext criteria
End If
If rs.NoMatch Then
MsgBox ("No have matched recordes !")
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close: Set rs = Nothing
End Sub
Private Sub txt_AfterUpdate()
mFlg = False
End Sub
Where "Device LLI" is Text, no case in sensetive
And if you want to my ACCESS mdb, send a mail let me know. Because there
are no accept attachment.
Message #4 by "Yehuda Rosenblum" <Yehuda@I...> on Thu, 26 Jul 2001 09:10:10 -0400
|
|
Sorry to piggyback off your answer Miriam, but I seem to have lost the
original email. I believe the problem with Raingo's code is his Like
statement. I may be wrong but I think you need double quotes not single
quotes around the clause to accomplish this, I think your statement
should be:
criteria =3D "Device LLI Like ""*" & Me!txt & "*"""
I could be wrong, but test this out and tell me what happens.
Yehuda
-----Original Message-----
From: Miriam Engelberg [mailto:MiriamE@c...]
Sent: Wednesday, July 25, 2001 6:25 PM
To: Access
Subject: [access] RE: How to add search command inside the ACCESS 2000
I'd suggest using the automated wizard to add a search combo box. If you
are interested in doing your own in future, you can look at the code
inserted by the wizard to learn how it works. To use the wizard, go into
design view of the form, make sure the Toolbox is visible (the toolbar
with form design buttons), click on the Combo Box button, then click in
the form. Choose the 3rd option, which says something like: Find a
record on my form based on the value I selected in my combo box. (If the
wizard doesn't start up, make sure the Wizards button is pressed in on
the toolbox.) Send over the ID field first, and then any other fields
you wish to see in the box (Last name, first name, etc.). Leave the ID
field hidden, as the wizard recommends.
Hope this helps!
Miriam
-----Original Message-----
From: Raingo [mailto:raingo@h...]
Sent: Tuesday, July 24, 2001 8:57 PM
To: Access
Subject: [access] How to add search command inside the ACCESS 2000
Hi, all,
I'm a beginner, with my homework, i want to add a command button
such as search command, it can be automatic find out matched record and
goto display this matched record at same page. But when i write a VBA
script, it is no success, Could you help me to modify it? Thank you so
much.
Thanks all of lots!
Raingo
VBA Script:
Option Compare Database
Option Explicit
Private mFlg As Boolean
Private Sub Form_Load()
mFlg =3D False
End Sub
Private Sub Search_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim criteria As String
Set db =3D CurrentDb()
Set rs =3D Me.Recordset.Clone
rs.Bookmark =3D Me.Bookmark
criteria =3D "Device LLI Like '*" & Me!txt & "*'"
If mFlg =3D False Then
rs.FindFirst criteria
mFlg =3D True
Else
rs.FindNext criteria
End If
If rs.NoMatch Then
MsgBox ("No have matched recordes !")
Else
Me.Bookmark =3D rs.Bookmark
End If
rs.Close: Set rs =3D Nothing
End Sub
Private Sub txt_AfterUpdate()
mFlg =3D False
End Sub
Where "Device LLI" is Text, no case in sensetive
And if you want to my ACCESS mdb, send a mail let me know. Because
there are no accept attachment.
|
|
 |