A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Search button on form



 
 
Thread Tools Display Modes
  #1  
Old September 30th, 2007, 11:34 AM posted to microsoft.public.access.forms
Allan Murphy[_2_]
external usenet poster
 
Posts: 12
Default Search button on form

Do you have a unique field that identifies the record e.g record_ref as an
autonumber?

Try this code
Private Sub SearchBatter_Click()

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[record_ref] = " & str(Me![NameDropDown])
Me.Bookmark = rs.Bookmark
end sub

"Shael" wrote in message
...
I have a form that is bound to a query. When I first open up the form, the
form displays fields from the first record.

On the same form, I have a drop down (NameDropDown) and a command button
(SearchBatter). What I want to happen is when the user selects an item

from
the drop down and clicks the command button, I want the form to display

the
fields that relate to the value in the drop down.

I have the following code in the Click event of the command button:

Private Sub SearchBatter_Click()
Dim strWhere As String
Dim strName As String

strName = Me.NameDropDown
strWhere = "([Name] = """ & strName & """)"
Me.Filter = strWhere
Me.FilterOn = True
End Sub

When I select a value from the drop down and click the button, nothing
changes in the form.

Can you help?



  #2  
Old September 30th, 2007, 11:05 PM posted to microsoft.public.access.forms
Shael
external usenet poster
 
Posts: 24
Default Search button on form

I have a form that is bound to a query. When I first open up the form, the
form displays fields from the first record.

On the same form, I have a drop down (NameDropDown) and a command button
(SearchBatter). What I want to happen is when the user selects an item from
the drop down and clicks the command button, I want the form to display the
fields that relate to the value in the drop down.

I have the following code in the Click event of the command button:

Private Sub SearchBatter_Click()
Dim strWhere As String
Dim strName As String

strName = Me.NameDropDown
strWhere = "([Name] = """ & strName & """)"
Me.Filter = strWhere
Me.FilterOn = True
End Sub

When I select a value from the drop down and click the button, nothing
changes in the form.

Can you help?
  #3  
Old October 1st, 2007, 12:52 AM posted to microsoft.public.access.forms
Shael
external usenet poster
 
Posts: 24
Default Search button on form

I tried this but I got the same result. It's like clicking on the Search
button is doing nothing.

"Allan Murphy" wrote:

Do you have a unique field that identifies the record e.g record_ref as an
autonumber?

Try this code
Private Sub SearchBatter_Click()

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[record_ref] = " & str(Me![NameDropDown])
Me.Bookmark = rs.Bookmark
end sub

"Shael" wrote in message
...
I have a form that is bound to a query. When I first open up the form, the
form displays fields from the first record.

On the same form, I have a drop down (NameDropDown) and a command button
(SearchBatter). What I want to happen is when the user selects an item

from
the drop down and clicks the command button, I want the form to display

the
fields that relate to the value in the drop down.

I have the following code in the Click event of the command button:

Private Sub SearchBatter_Click()
Dim strWhere As String
Dim strName As String

strName = Me.NameDropDown
strWhere = "([Name] = """ & strName & """)"
Me.Filter = strWhere
Me.FilterOn = True
End Sub

When I select a value from the drop down and click the button, nothing
changes in the form.

Can you help?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.