Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Find Command Button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jen - 31 Oct 2006 08:15 GMT
On my main form I have a command button for the function Find Records.  
However I want it only to search one field.

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

When I click on the command button it wants to search [Caller]
I want it only to search [DDLID] everytime.  Is this possible.

Thanks Jen
SteveS - 31 Oct 2006 11:20 GMT
Jen,

Are you saying that if you set the focus to [DDLID], the focus moves to
[Caller], then finds records?

If so, change this line - add a single quote at the front (ie - comment out
the line)

' Screen.PreviousControl.SetFocus
^

Then try the code.

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> On my main form I have a command button for the function Find Records.  
> However I want it only to search one field.
[quoted text clipped - 6 lines]
>
> Thanks Jen
Jen - 31 Oct 2006 12:01 GMT
This in not what I am looking for.  When I and the ' it only searches the
current record.  I want it to search all my records but only the field
[DDLID].

I am not sure how to set the Focus to [DDLID] because when the form opens
[Caller] is the first field to be filed out.

Thanks
Jen

> Jen,
>
[quoted text clipped - 21 lines]
> >
> > Thanks Jen
SteveS - 01 Nov 2006 09:16 GMT
OK,

Would you post the code for your FIND button?

Rather than use FIND, it is easier to filter the recordset.

Like Klatuu said, you could put an unbound text box in the header of the
form and add two buttons. One button would set the filter and the other would
remove the filter.

If [DDLID] is numeric and the text box in the header is named "Text8", the
following code will show only records that match what is entered in the text
box:

(Change Text8 to the name of your text box)

' filter records
Private Sub SetFilterOn_Click()
  Me.Filter = "[DDLID] = " & Me.Text8
  Me.FilterOn = True
End Sub

' remove the filter
Private Sub SetFilterOff_Click()
  Me.FilterOn = False
End Sub

If [DDLID] is text, use the fillowing code:

'filter records
Private Sub SetFilterOn_Click()
  Me.Filter = "[DDLID] = '" & Me.Text8 & "'"
  Me.FilterOn = True
End Sub

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> This in not what I am looking for.  When I and the ' it only searches the
> current record.  I want it to search all my records but only the field
[quoted text clipped - 31 lines]
> > >
> > > Thanks Jen
Klatuu - 01 Nov 2006 15:06 GMT
Were I doing it, I would use only one button.

' filter records
Private Sub SetFilter_Click()
   If Me.SetFilter.Caption = "Set Filter" Then
       Me.Filter = "[DDLID] = " & Me.Text8
       Me.FilterOn = True
       Me.SetFilter.Caption = "Clear Filter"
   Else
       Me.FilterOn = False
       Me.SetFilter.Caption = "Set Filter"
   End If
End Sub

> OK,
>
[quoted text clipped - 68 lines]
> > > >
> > > > Thanks Jen
Klatuu - 31 Oct 2006 16:22 GMT
What are you searching for,  What are you going to do when  you find a match?
What happens when you don't find a match?

See VBA Help regarding  DoMenuItem.  It was replaced with RunCommand in 97
and only there for backward compatibility.

A better way to execute a search for a specific value in a field is to use
an unbound combo box.

> On my main form I have a command button for the function Find Records.  
> However I want it only to search one field.
[quoted text clipped - 6 lines]
>
> Thanks Jen
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.