Solved

Accessing Recordset for Data Control

Posted on 2002-06-24
9
142 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

759 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

21 Experts available now in Live!

Get 1:1 Help Now