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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|