I'm trying to get this snipet of code to work for me, but I'm having trouble. The code is to, connect to my db (works), loop trough/.additem from !jobnumber (works) & populate some textboxes on my form (I'm only trying to get "txtJobName" to populate for the time being, but it doesn't work).
Here's my code:
Private Sub Form_Load()
Dim adoConn As ADODB.Connection
Dim adoRs As ADODB.Recordset
Dim connStr As String
Dim strSql As String
Do Until adoRs.EOF
cmbJobNumber.ListIndex = 0
strSql = "select job.jobname from job where job.jobnumber is " & cmbJobNumber.Text
If Not adoRs.EOF And adoRs.BOF Then '<---
Me.txtJobName.Text = adoRs.Fields!jobname '<---
Me.txtJobName.Text = "" '<---
Set adoRs = Nothing
Set adoConn = Nothing
I'm accustom to VBA, but I'm trying to learn VB. The trouble I'm having is getting txtJobName to populate with the correct fields value, it only the "" as coded in the else statement. I've tried other combinations of code, but I start getting BOF & EOF run-time errors. Can someone fill me in as to why this code doesn't work??
The reason is that before the text box code you are looping until the recordset hits eof. Since it hits eof, you will never see anything from this recordset unless you do a movefirst/moveprevious. However, what do you want to show in the text box - only 1 value can be displayed ?