P
peddie
Hi
I am super newbie to writing VBA and I would like to ask for any of
your help please.
It is so simple but I dont where to start. i would like to set up a
text box which I could enter a string to search for name within the
database, and I would like the result to show in the Value list which
sits on the same form.
Then i want to be able to pick one value from the searh result in the
Value List and click the button to continue (by Continue I mean open a
new form that displays the selected record)
Any idea how to do this please?
This is the code
Private Sub Command4_Click()
'Declare the object variables
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String
List0.Visible = True
'Instantiate the objects and open the recordset
Set db = CurrentDb
strSQL = "SELECT * from Name where FullName = " & _
" Form!NameSearch!nmsearch"
Set rs = db.OpenRecordset(strSQL)
rs.Filter = Form!namesearch!nmsearch
List0.RowSource = nmsearch
'Clean up afterwards
On Error Resume Next
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
I seemed to get no where with this
Many thanks in advance
peddie
I am super newbie to writing VBA and I would like to ask for any of
your help please.
It is so simple but I dont where to start. i would like to set up a
text box which I could enter a string to search for name within the
database, and I would like the result to show in the Value list which
sits on the same form.
Then i want to be able to pick one value from the searh result in the
Value List and click the button to continue (by Continue I mean open a
new form that displays the selected record)
Any idea how to do this please?
This is the code
Private Sub Command4_Click()
'Declare the object variables
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String
List0.Visible = True
'Instantiate the objects and open the recordset
Set db = CurrentDb
strSQL = "SELECT * from Name where FullName = " & _
" Form!NameSearch!nmsearch"
Set rs = db.OpenRecordset(strSQL)
rs.Filter = Form!namesearch!nmsearch
List0.RowSource = nmsearch
'Clean up afterwards
On Error Resume Next
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
I seemed to get no where with this
Many thanks in advance
peddie