Solved

Accessing Recordset for Data Control

Posted on 2002-06-24
9
143 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:zippy221
9 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7104126
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
 

Expert Comment

by:mudasir_ahmed
ID: 7104205
Hi Zippy,
  Try moving to the record using .Movenext or .Move (Record Number).

-Mudasir.
0
 

Author Comment

by:zippy221
ID: 7104290
How do I know what the record number is?
0
 

Author Comment

by:zippy221
ID: 7104293
I tried leaving out the close and open recordset, but that doesn't seem to work either...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7104650
using text property of dbcombo?
0
 

Author Comment

by:zippy221
ID: 7105462
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
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 70 total points
ID: 7105523
Well, not use Double quotes:
SearchCriteria1 = "[Employee]= '" & cboAccountInformation1 & "'"
0
 

Author Comment

by:zippy221
ID: 7114220
You are a awesome!  Thanks!

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7114325
yeah, yeah, i know :)))
Thanks for "A" grade!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now