Search Box

R

Rhett_Y

Hi all.. I was able to get my other question answered buy now I have a new
one..

I have the following tables and code:

I am using the following search function to search my database:

Private Sub cmdSearch2_Click()
Dim strLastName As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch2]) Or (Me![txtSearch2]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch2].SetFocus
Exit Sub
End If
'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("LastName")
DoCmd.FindRecord Me!txtSearch2
LastName.SetFocus
strLastName = LastName.Text
txtSearch2.SetFocus
strSearch = txtSearch2.Text
'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control
If strLastName = strSearch Then
'MsgBox "Match Found For: " & strSearch, , "Congratulations!"
LastName.SetFocus
'txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch2.SetFocus
End If
End Sub
Which i got from here: http://www.databasedev.co.uk/text_search.html

Question #1

I have my own record counter setup at the bottom of the form via this:

Private Sub Form_Current()
'Inserts current record number and total number of records
Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast
Me.txtTotal = Me.RecordsetClone.RecordCount
End Sub

The bottom part is the counter. Is it possible with the way I have the
search code setup to do the following:

(I now have a lblbox next to the last name that shows me how many "johnson"
i have in the database) But what i want to do is have setup so that when the
person enters in johnson it lets them know they have 3 (for example). I have
the counter buttons at the bottom. What I would like to be able to do is
have it setup so when they push the next record botton it shows the next
johnson record... not the next record in the database... I thought by having
the table set to a-->z it would carry over onto the form..but it doesn't....
So how can I do this??

Thanks again
R~
 
M

Marcin

Rhett_Y said:
Hi all.. I was able to get my other question answered buy now I have a new
one..

I have the following tables and code:

I am using the following search function to search my database:

Private Sub cmdSearch2_Click()
Dim strLastName As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch2]) Or (Me![txtSearch2]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch2].SetFocus
Exit Sub
End If
'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("LastName")
DoCmd.FindRecord Me!txtSearch2
LastName.SetFocus
strLastName = LastName.Text
txtSearch2.SetFocus
strSearch = txtSearch2.Text
'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control
If strLastName = strSearch Then
'MsgBox "Match Found For: " & strSearch, , "Congratulations!"
LastName.SetFocus
'txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch2.SetFocus
End If
End Sub
Which i got from here: http://www.databasedev.co.uk/text_search.html

Question #1

I have my own record counter setup at the bottom of the form via this:

Private Sub Form_Current()
'Inserts current record number and total number of records
Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast
Me.txtTotal = Me.RecordsetClone.RecordCount
End Sub

The bottom part is the counter. Is it possible with the way I have the
search code setup to do the following:

(I now have a lblbox next to the last name that shows me how many "johnson"
i have in the database) But what i want to do is have setup so that when the
person enters in johnson it lets them know they have 3 (for example). I have
the counter buttons at the bottom. What I would like to be able to do is
have it setup so when they push the next record botton it shows the next
johnson record... not the next record in the database... I thought by having
the table set to a-->z it would carry over onto the form..but it doesn't....
So how can I do this??

Thanks again
R~


=====================================================
FULL LEGAL SOFTWARE !!!
Games, video, program, image, chat, questbook, catalog site, arts, news,
and...
This site it is full register and legal software !!!
Please download and you must register software !!!

PLEASE REGISTER SOFTWARE:
http://www.webteam.gsi.pl/rejestracja.htm
DOWNLOAD LEGAL SOFTWARE:
http://www.webteam.gsi.pl

Full question and post: http://www.webteam.gsi.pl

Contact and service and advanced technology:
http://www.webteam.gsi.pl/kontakt.htm
FAQ: http://www.webteam.gsi.pl/naj_czesciej_zadawane_pytania.htm

Please add me URL for you all site and search engines and best friends !!!

Me site:
SERWIS WEBNETI: http://www.webneti.gsi.pl
PORTAL WEBTEAM: http://www.webteam.gsi.pl
LANGUAGE: http://www.webneti.cjb.net
==========================================================
 
R

Rhett_Y

Hi again...

I think I may be on to it..but I cant get it to work.. What I did is
created a query that would activate off of the "Search Button".... I can get
the button to open the query when I type in the last name and it shows me the
entries for the just that last name.. but how would I get it to populate the
fields in my form?

I used this to start off with:

Private Sub cmdSearch2_click()
DoCmd.openquery "qryAllRecords2", acViewNormal, acEdit
End Sub

The query is setup so that all the fields on the form are the same from the
tblMain and those fields are on the form...

R~

Rhett_Y said:
Hi all.. I was able to get my other question answered buy now I have a new
one..

I have the following tables and code:

I am using the following search function to search my database:

Private Sub cmdSearch2_Click()
Dim strLastName As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch2]) Or (Me![txtSearch2]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch2].SetFocus
Exit Sub
End If
'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("LastName")
DoCmd.FindRecord Me!txtSearch2
LastName.SetFocus
strLastName = LastName.Text
txtSearch2.SetFocus
strSearch = txtSearch2.Text
'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control
If strLastName = strSearch Then
'MsgBox "Match Found For: " & strSearch, , "Congratulations!"
LastName.SetFocus
'txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch2.SetFocus
End If
End Sub
Which i got from here: http://www.databasedev.co.uk/text_search.html

Question #1

I have my own record counter setup at the bottom of the form via this:

Private Sub Form_Current()
'Inserts current record number and total number of records
Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast
Me.txtTotal = Me.RecordsetClone.RecordCount
End Sub

The bottom part is the counter. Is it possible with the way I have the
search code setup to do the following:

(I now have a lblbox next to the last name that shows me how many "johnson"
i have in the database) But what i want to do is have setup so that when the
person enters in johnson it lets them know they have 3 (for example). I have
the counter buttons at the bottom. What I would like to be able to do is
have it setup so when they push the next record botton it shows the next
johnson record... not the next record in the database... I thought by having
the table set to a-->z it would carry over onto the form..but it doesn't....
So how can I do this??

Thanks again
R~
 

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

Similar Threads


Top