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
Set adoConn = New ADODB.Connection
Set adoRs = New ADODB.Recordset
connStr = "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Data Source=C:\program files\dci job folders\db1.mdb"
adoConn.Open connStr
adoRs.Open "job", adoConn
Do Until adoRs.EOF
cmbJobNumber.AddItem adoRs!jobnumber
adoRs.MoveNext
Loop
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 '<---
Else '<---
Me.txtJobName.Text = "" '<---
End If
adoRs.Close
adoConn.Close
Set adoRs = Nothing
Set adoConn = Nothing
End Sub
~~~~~~~~~~~~~~~~~~~~~~
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??
Thanks,
Mark