Accessing Recordset for Data Control

I have a dbCombo box that uses the objAcctInfo1 datacontrol.  I want to be able to select a name from the combo box and then when I press a button, it will set the variable strTitle1 to the Title for that name in the database...my problem is that when I debug this code it is always at the first record of the recordset, not at the record I need.  I just need to know how to move the pointer to the record I need...what would I add to this code to do that?  It would need to point to the record where cboName = the Name field in the objAcctInfo1 data control recordset.

With Me.objAcctInfo1.Recordset
.OpenRecordset
 strTitle1 = ![Title]
.Close
End With

Thanks,

Zippy221
zippy221Asked:
Who is Participating?
 
Richie_SimonettiConnect With a Mentor IT OperationsCommented:
Well, not use Double quotes:
SearchCriteria1 = "[Employee]= '" & cboAccountInformation1 & "'"
0
 
TimCotteeHead of Software ServicesCommented:
You don't need to re-open and close the recordset each time, this will reset to the first record:

With Me.objAcctInfo1.Recordset
strTitle1 = ![Title]
End With
0
 
mudasir_ahmedCommented:
Hi Zippy,
  Try moving to the record using .Movenext or .Move (Record Number).

-Mudasir.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
zippy221Author Commented:
How do I know what the record number is?
0
 
zippy221Author Commented:
I tried leaving out the close and open recordset, but that doesn't seem to work either...
0
 
Richie_SimonettiIT OperationsCommented:
using text property of dbcombo?
0
 
zippy221Author Commented:
That doesn't work either...here is what I tried:

Dim strTitle1 As String
Dim SearchCriteria1 As String

SearchCriteria1 = "[Employee]= " & Chr$(34) & cboAccountInformation1 & Chr$(34)

With Me.objAcctInfo1.Recordset
    .FindFirst SearchCriteria1
    strTitle1 = ![Title]
End With

When I debug it the search criteria is okay, but the title doesn't change it is still not moving to the record it is on...
0
 
zippy221Author Commented:
You are a awesome!  Thanks!

0
 
Richie_SimonettiIT OperationsCommented:
yeah, yeah, i know :)))
Thanks for "A" grade!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.