Link to home
Start Free TrialLog in
Avatar of zippy221
zippy221

asked on

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
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of mudasir_ahmed
mudasir_ahmed

Hi Zippy,
  Try moving to the record using .Movenext or .Move (Record Number).

-Mudasir.
Avatar of zippy221

ASKER

How do I know what the record number is?
I tried leaving out the close and open recordset, but that doesn't seem to work either...
Avatar of Richie_Simonetti
using text property of dbcombo?
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...
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are a awesome!  Thanks!

yeah, yeah, i know :)))
Thanks for "A" grade!