I have been wresting with populating my list box and now its working however the layout isnt quite what i want.
So far the layout is below
1234
jones
5678
smith
i want it to be
1234 jones
5678 smith
so each row of associated date is on one line
the code im current using is below:
Private Sub cmdFind_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim phone As Integer
phone = txtPhoneNum
Dim sqlCustomer As String
Dim n As Integer
Set db = CurrentDb()
sqlCustomer = "SELECT * FROM [tblCustomers] WHERE [PhoneNum] LIKE '" & Me.txtPhoneNum & "*'"
Set rs = db.OpenRecordset(sqlCustomer, dbOpenDynaset)
Do Until rs.EOF = True
lstRecords.AddItem rs.Fields("intAccNum")
lstRecords.AddItem rs.Fields("strName")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
thanks for your help in advance
So far the layout is below
1234
jones
5678
smith
i want it to be
1234 jones
5678 smith
so each row of associated date is on one line
the code im current using is below:
Private Sub cmdFind_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim phone As Integer
phone = txtPhoneNum
Dim sqlCustomer As String
Dim n As Integer
Set db = CurrentDb()
sqlCustomer = "SELECT * FROM [tblCustomers] WHERE [PhoneNum] LIKE '" & Me.txtPhoneNum & "*'"
Set rs = db.OpenRecordset(sqlCustomer, dbOpenDynaset)
Do Until rs.EOF = True
lstRecords.AddItem rs.Fields("intAccNum")
lstRecords.AddItem rs.Fields("strName")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
thanks for your help in advance