Search form??

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

Guest

Hello,

I am stuck on trying to make a form which searches for a
particular record, for example the search field is the
Project Number.
Basicly I would like to make a simple form which has a
text box where people can enter what project number they
are looking for and a button that says "search".
I tried doing it with a macro's but it gives me an error
message.
Has anyone done anything similar.

Any help would be tops.

Cheers
 
Hi,
if you already have a form with the information on it just go to the toolbar and click on the binoculars which will allow you to search for any record based on any field. If you haven't then you can automatically create a form based on the underlying table using the wizard.
You can also use this facility in the table view. Hope this helps
 
This is a simple solution
Use the query wizard to build a new query based on the table or other
query you want to search. { use the simple query wizard )
Select the all the necessary fields from the available fields, click
next until you get to the box that asks you to name the query & name
the query as it suits you click finish.
Now open the query in Design mode Find the field named 'Project number'
and in the Criteria row, enter the next line

[Enter Your Project number]
and close the query.
Now in the database window - highlight your new query and then use the
Autoform wizard to create your new form.
Now when you invoke that form you'll get a prompt box that asks you to
Enter your Project Number - enter the required number and up will come
the form with all the details for that project.
Re-design the form if you don't like the wizard solution.


You could also use this criteria line to search for a record

Like "xx*"
where xx is the first couple of digits or letters in a record.
For instance You have a list of customers and you want to find alll
those names beginning BR - the entry would be Like "BR*"

Have fun
 
Hi Linda,

It is possible to do that but the other people who
willhave to use this database wont know about the
binoculors on the main toolbar. I was hoping to create a
buttom which doe sthe same thing??

I can't figure out how to manipulate the Macro bit.

Any help
-----Original Message-----
Hi,
if you already have a form with the information on it
just go to the toolbar and click on the binoculars which
will allow you to search for any record based on any
field. If you haven't then you can automatically create a
form based on the underlying table using the wizard.
 
Anonymous,
I gave you one solution - Here's another....
On your main form add a new button using the command button wizard us
Categories Record Navigation > Actions Find Record.
Now when user has the Project Number field in focus - hit the fin
record (or whatever you have called it)button for a prompt to Look i
Project number.
This button will work on any Field on your form that has the curren
focus
 
Here is some code I did for searching a form of students. I put a fin
button on the main form that opened up my search form with just on
field on it and two buttons. You can play around with the code and ad
a drop down to select the different fields etc. Hopefully you can adap
this code.


Code
-------------------

Option Compare Database
Option Explicit

Private Sub cmdCancel_Click()

DoCmd.Close acForm, "frmFindStudent", acSaveYes

End Sub

Private Sub cmdFind_Click()
On Error GoTo ErrorH

Dim sCriteria As String

Select Case Me.cmdFind.Caption
Case "&Find"
Form_frmStDetails.SetFocus
Form_frmStDetails.StFirst.SetFocus
sCriteria = Form_frmFindStudent.txtCriteria
DoCmd.FindRecord sCriteria, acAnywhere, False, acSearchAll, False, acAll, True
Form_frmFindStudent.SetFocus
Me.cmdFind.Caption = "&Find Next"
Case "&Find Next"
Form_frmStDetails.SetFocus
Form_frmStDetails.StFirst.SetFocus
DoCmd.FindNext
Form_frmFindStudent.SetFocus
End Select

SubEnd:
Exit Sub

ErrorH:
MsgBox Err.Description
Resume SubEnd

End Sub

Private Sub txtCriteria_Change()
On Error GoTo ErrorH:

If Me.cmdFind.Caption = "&Find Next" Then
Me.cmdFind.Caption = "&Find"
End If

SubEnd:
Exit Sub

ErrorH:
MsgBox Err.Description
Resume SubEnd
End Sub
 
dbatleedsmet said:
This is a simple solution
Use the query wizard to build a new query based on the table or other
query you want to search. { use the simple query wizard )
Select the all the necessary fields from the available fields, click
next until you get to the box that asks you to name the query & name
the query as it suits you click finish.
Now open the query in Design mode Find the field named 'Project number'
and in the Criteria row, enter the next line

[Enter Your Project number]
and close the query.
Now in the database window - highlight your new query and then use the
Autoform wizard to create your new form.
Now when you invoke that form you'll get a prompt box that asks you to
Enter your Project Number - enter the required number and up will come
the form with all the details for that project.
Re-design the form if you don't like the wizard solution.


You could also use this criteria line to search for a record

Like "xx*"
where xx is the first couple of digits or letters in a record.
For instance You have a list of customers and you want to find alll
those names beginning BR - the entry would be Like "BR*"

Have fun
 
Back
Top