I just know that the answer to this question is going to be simple but it elludes me at the moment and I cannot find an answer through a search on this site.
I am developing an application for a friend dealing with ticket sales. I have included the block of code below.
I am using VB6.0 SP5 and an Access 2000 database and accessing my recordsets through code.
What has to happen is the user clicks a phone number from a list box and the .text from the listbox is assigned to a string. Then I use an SQL statement to extract information from the database using the string to populate text boxes with data from certain fields of the table. (all the data is coming from the same table)
I am stumped as to how to make the data appear in the textboxes..I have tried
txtfirstname.text = rscustomer(strsql.. no results
with txtfirstname
.datafield = !firstname
set .datasource = rscustomer(strSQL)... error...
along with a host of other attempts.
I think that I am so wrapped up in trying to find a solution that I cannot see the answer.
Here is the code:
Private Sub lstCustPhNumber_Click()
On Error GoTo Errclose
txtFirstName.Text = ""
txtLastName.Text = ""
txtSalesAddress.Text = ""
txtSalesPhone.Text = ""
Dim strSQL As String
Dim strPhone As String
strPhone = lstCustPhNumber.Text
strSQL = "SELECT firstname, lastname, address,phone FROM customer WHERE phone = '" & strPhone & "'"
rsCustomer.Open (strSQL)
<insert the textbox code here>
Exit Sub
Errclose:
rsCustomer.Close
rsCustomer.Open
Resume Next
End Sub
just for extra measure here is the block of code that fills the listbox
Private Sub LoadCustomer()
On Error GoTo Errclose
lstCustPhNumber.Clear
With rsCustomer
.MoveFirst
Do While rsCustomer.EOF = False
lstCustPhNumber.AddItem !phone
.MoveNext
Loop
End With
Exit Sub
Errclose:
rsCustomer.Close
rsCustomer.Open
Resume Next
End Sub
any help would be greatly appreciated.
Thank You
zgtrman To effectively improve in the efficiency of your performance, one must be proficient in the implementation of a positive mental attitude.
I am developing an application for a friend dealing with ticket sales. I have included the block of code below.
I am using VB6.0 SP5 and an Access 2000 database and accessing my recordsets through code.
What has to happen is the user clicks a phone number from a list box and the .text from the listbox is assigned to a string. Then I use an SQL statement to extract information from the database using the string to populate text boxes with data from certain fields of the table. (all the data is coming from the same table)
I am stumped as to how to make the data appear in the textboxes..I have tried
txtfirstname.text = rscustomer(strsql.. no results
with txtfirstname
.datafield = !firstname
set .datasource = rscustomer(strSQL)... error...
along with a host of other attempts.
I think that I am so wrapped up in trying to find a solution that I cannot see the answer.
Here is the code:
Private Sub lstCustPhNumber_Click()
On Error GoTo Errclose
txtFirstName.Text = ""
txtLastName.Text = ""
txtSalesAddress.Text = ""
txtSalesPhone.Text = ""
Dim strSQL As String
Dim strPhone As String
strPhone = lstCustPhNumber.Text
strSQL = "SELECT firstname, lastname, address,phone FROM customer WHERE phone = '" & strPhone & "'"
rsCustomer.Open (strSQL)
<insert the textbox code here>
Exit Sub
Errclose:
rsCustomer.Close
rsCustomer.Open
Resume Next
End Sub
just for extra measure here is the block of code that fills the listbox
Private Sub LoadCustomer()
On Error GoTo Errclose
lstCustPhNumber.Clear
With rsCustomer
.MoveFirst
Do While rsCustomer.EOF = False
lstCustPhNumber.AddItem !phone
.MoveNext
Loop
End With
Exit Sub
Errclose:
rsCustomer.Close
rsCustomer.Open
Resume Next
End Sub
any help would be greatly appreciated.
Thank You
zgtrman To effectively improve in the efficiency of your performance, one must be proficient in the implementation of a positive mental attitude.