Solved

Accessing Recordset for Data Control

Posted on 2002-06-24
9
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zippy221
ID: 7104293
I tried leaving out the close and open recordset, but that doesn't seem to work either...
0
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

726 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