Searching for a record in ADO vs DAO

Hi, I found this example code in the newsgroup here and it is what I
need to do, but I am using ADO instead of DAO.  I have successfully
coded all of my record navigation (movefirst, movennext, add new,
delete, etc) so far.  I am using a query on an unbound combo box on an
unbound form using the afterupdate property event to go to a specific
record.

I need help adapting this example to ADO since the methods obviously
wont work with my current configuration.  Thank you for your help.

Private Sub cboFindContact_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[FieldToSearch] = " & cboFindRecord
If rs.NoMatch Then
  MsgBox "Not Found"
  rs.MoveFirst
End If
Me.Bookmark = rs.Bookmark
Set rs = Nothing
End Sub

0
Joe
2/11/2008 12:04:51 AM
access.forms 6864 articles. 2 followers. Follow

1 Replies
1040 Views

Similar Articles

[PageSpeed] 5

"Joe" <timlayton@gmail.com> wrote in message 
news:32e6a17a-f7fb-4a8e-8cab-9c625064c933@e4g2000hsg.googlegroups.com...
> Hi, I found this example code in the newsgroup here and it is what I
> need to do, but I am using ADO instead of DAO.  I have successfully
> coded all of my record navigation (movefirst, movennext, add new,
> delete, etc) so far.  I am using a query on an unbound combo box on an
> unbound form using the afterupdate property event to go to a specific
> record.
>
> I need help adapting this example to ADO since the methods obviously
> wont work with my current configuration.  Thank you for your help.
>
> Private Sub cboFindContact_AfterUpdate()
> Dim rs As DAO.Recordset
> Set rs = Me.RecordsetClone
> rs.FindFirst "[FieldToSearch] = " & cboFindRecord
> If rs.NoMatch Then
>  MsgBox "Not Found"
>  rs.MoveFirst
> End If
> Me.Bookmark = rs.Bookmark
> Set rs = Nothing
> End Sub


So you're saying that your form's recordset is an ADO recordset, not a DAO 
recordset?  Is that because you're working in an ADP file, or did you 
explcitly set the form's Recordset property to an ADO recordset that you 
opened?

If your form's recordset is an ADO recordset, then the equivalent find code 
would look like this, I think:

'----- start of code -----
Private Sub cboFindContact_AfterUpdate()

    With Me.RecordsetClone
        .Find "[FieldToSearch] = " & Me!cboFindContact
        If .EOF Then
            MsgBox "Not Found"
            .MoveFirst
        End If
        Me.Bookmark = .Bookmark
    End With

End Sub
'----- end of code -----

-- 
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

0
Dirk
2/11/2008 1:17:00 AM
Reply:

Similar Artilces:

Simple Query only returning 5 records
I am very new to Access, therefore I'm pretty sure I know where the problem is. That said...I have a query built of multiple imported tables. I'm mostly using it to combine values for data analysis. I have been changing the query up and rerunning it over and over. Yesterday I got some error that said I didn't have enough memory or disk space to finish the query. Now I can only get 5 records out when I run the query. I don't know if the two are related but something is up. In trying to discover the issue I have deleted all table connections and simply tried to return all the val...

Search last 4 digits in an (account number)
I store bank accunt and credit card numbers in various Contact Notes. For example, a credit card # as xxxxxxxxxxxx1234. Outlook contact search would not find this contact if I enter the search for "1234". Is there a way to do this in Outlook 2007? TIA PS - this search works fine in Outlook Mobile. outlook searches from the beginning - so it will only work if you use xxxxxxxxxxxx 1234. Other search tools (like google desktop) may find it. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: htt...

Look for: Search In => Choose folders=> Search subfolders not working
When I search for an old email using Outlook's Look for: box and specify which folders to search in via the "Choose folders=>Search subfolders" checking a folder does not actually cause any subfolders to be checked. Unless there is some other setting and/or option hidden away somewhere, the "Search subfolders" check box is not working. I must manually check all the desired subfolders. What am I doing wrong? -- Regards, Peter Sale Santa Monica, CA USA To email me, just pull 'my-leg.' ...

Creating related records
We’ve found tons of blogs on displaying related records (that have already been created) from within an iframe but are wondering if you can actually create a related record from within an iframe? For example you are in a Case and want to create a new related account. We would like to click on an "Account" tab within the Case and select a button called "Create" or "New" and have the account form display, the account information can then be entered, the account can be saved, and then it will display in the Account tab of the case. Depending on your content ...

grouping multiple records on joined table
I have 2 tables TABLE A | id | name | | 1 | John | | 2 | David | | 3 | Adam | TABLE B | id | colors | | 1 | blue | | 1 | red | | 1 | yellow | | 2 | blue | | 3 | green | | 3 | black | When I join the tables by ID I get | 1 | John | blue | | 1 | John | red | | 1 | John | yellow | | 2 | David | blue | | 3 | Adam | green | | 3 | Adam | black | I would like to merge all the records from table B into one field for each record from table A: | 1 | John | blue, red, yellow | | 2 | John | blue | | 3 | Adam | green, black | Thanks for all help, Jack MS tells you that you can have multiple values in...

Searching for Newsgroups
I subscribe to a Usenet service for accessing various news groups. After I download all the newsgroups from that server I can not find a way to search for the newsgroups I have interest in. When I put something like "RV" in the search box on the top right corner, it searches all of my Emails rather than just the list of groups that had "RV" in the title. Help tells me that there is a " Display newsgroups containing" box but for the life of me I can't find it. Any thoughts out there? I am running Entourage 12.2.3 Dunc Click the bar in th...

Search & replace in formulae
Is it possible to do a search and replace which includes the cell formula contents ? I have a workbook that has cells which link to the contents of a cell in another workbook and I'd like to know if the naming has to remain constant or if I can replace a part of the name periodically. ie each year. thanks "Iain Rhodes" <iain@pricejam.com> wrote in message news:8ec201c49682$858c5d20$a501280a@phx.gbl... > Is it possible to do a search and replace which includes > the cell formula contents ? I have a workbook that has > cells which link to the contents of a cel...

Workflow assignment of related records to account owner
Is there a way to have related records (quotes, opportunities and orders are what I am really concerned with) automatically assigned to the account owner if someone other than the account owner creates them? I would think this would be no big deal, but I have not been able to figure it out and think I am overlooking something. Our structure pairs an inside sales person with some number of outside sales people (anywhere from 1-4). The outside sales people own all of the customer accouts. If an inside sales person creates an opportunity, for example, for a particular account, I would ...

Should SSL Certificate Hostname=FQDN if MX record is different?
Hi, if I have MX records for "webmail.domain.com" but my Exchange host has a FQDN of "mail2.domain.com", will I have a problem with the certificate name not matching the address of the server and failing the SSL certificate authorization? Or would it be best if I add a new MX record using the FQDN and have users connect to that? Thank you, Will Hi, The certificate name must be the name that the users use when connecting from the internet. This name has nothing to do with the internal fqdn of the server and the MX record. Leif "Will Niccolls" <w...

Unmatched Records 01-11-10
Have 2 queries, one is "CustomerNoSales" and the other "CustomerSales", both queries have these 2 fields "CID" (customerID) and "PrdtID" (productID). I need to find out which records from the "PrdtID" field in the "CustomerSales" query that ARE NOT in the "CustomerNoSales" query. Have you tried the Query Wizard? Vanderghast, Access MVP "Mario" <Mario@discussions.microsoft.com> wrote in message news:5C005499-BB50-4002-B7E1-176C0D5EFF18@microsoft.com... > Have 2 queries, one is "Custom...

Search engine optimization
Hello all! My question today regarding this issue is: I have noticed some sites have the following on their sites "Source". meta name= "robots" content="Index, follow" meta name= "revisit-after" content="15 days" or (30 days) What does this function accomplish as far as search engines go? and will it really imporve your results ( rankings) Like for instance "robots" "index, all" what is the difference between this and saying "robots" "index, follow" I'm a bit confused about this. Can someone ...

Show all Records
I am using a combo box to filter my records in a List Box *2 problems the combo box is showing say "Transport" 6 times if I have transport in that field 6 times (No Duplicates Please) *When I select Transport it only shows 1 field, I am trying to get the list box to show all 6 fields (Show Duplicates) Combobox= Private Sub cmbFindSubject_AfterUpdate() Me!lstModify.RowSource = "SELECT * FROM qryClientInvoice Where [InvoiceID] Like " & Me.cmbFindSubject End Sub Query= SELECT tblInvoice.InvoiceID, tblInvoice.ClientDetail FROM tblInvoice WHERE (((tbl...

DoCmd to delete records
Hi I have a command button that when clicked deletes certain records from a subform based on an application number being equal. It deletes all records with the same applciation number as currently shown on the main form, see code below: DoCmd.RunSQL ("DELETE FROM tblAdultDetails WHERE [frmAdultDetails2].Form![ApplicationNum]=" + Str(Me.ApplicationNumber)) However I would like it to only delete records if the fields [MainApplicantFlag] =1 or [PartnerFlag] =1 as well as ApplicationNum being equal. These are both number fields btw. Can someone tell me what I should add to my code in...

Can I search identical fields from multiple tables?
I have a database to log details about staff in my school. I have a tables for staff details, courses, absence, educational visits etc. In each table I have a date field to show when the member of staff is not present. I want to produce a query to search all tables by entering a date - e.g. to bring back all results for staff who are not in school on a certiain day because they are either ill, on a course or on an educational visit. The query will work by entering a date once - it will then search all the other tables and bring back the results. Is this possible? Do I restructure? ...

How to register a contorl (dll) in VS 2005?
Hi, I have a shell extension application built in VS 6. I am porting the code to VS 2005. After porting, how can I register the dll from IDE? In VS 6, there is a option to register control from tools menu but I could not find the similar option in VS 2005. I am very new to this. So, please help me. (As workaround I am using the regsvr32 to register it after every built) Also, when I start the debuggin from VS 2005, the dll is locked by VS 2005. I have to close the IDE everytime to rebuild it. Can someone also provide some hints for this problem. Thanks, Anu > I have a shell extension app...

What does outlook search when you search Contacts ?
When you do a search in oulook for contacts, what is the criteria that outlook searches? Or I guess how does outlook search? Why is it not consistant? The reason I am asking is that we have our customers contacts in public folders. In our customers we have 6 contacts for XYZ Foods. If you search in outlook for just "XYZ" it only comes back with 4 of the six. If you do a search for "XYZ Foods" it returns with all 6. And if you just entered "Foods" no contacts were found. And we actually have a few companies in our contacts who's names are a two part name ending...

excel VBA
How would i search a range of a whole column instead of specific cells like .Range("a1:a300")? --- Message posted from http://www.ExcelForum.com/ ..range("a:a") ..columns(1) ..range("a1").entirecolumn are a few ways. "Zygoid <" wrote: > > How would i search a range of a whole column instead of specific cells > like .Range("a1:a300")? > > --- > Message posted from http://www.ExcelForum.com/ -- Dave Peterson ec35720@msn.com ahhh! Thanks!! I was trying .Column(1) i see i neede an "s" in there Thanks a...

Command Button To Delete Text In Single Field In Record
Hello All, I want to be able to do is open a particular form, which based on a table. "Enquirys" form is called "Enquiry_Date_Reset" On the form i want to scroll to a particular record and then press a button which will clear the date which is stored in the [Date Sent] field for that particular record set. (Not the whole record) is this possible? Regards Dan On Fri, 03 Aug 2007 09:08:56 -0700, dan.cawthorne@gmail.com wrote: > Hello All, > > I want to be able to do is open a particular form, which based on a > table. "Enquirys" > > form ...

Multiple fields using to search
Hi, Something i've been batteling for weeks with and theres probably such a simple answer to it and i just cant see it: Riiiight, i have this form (lets call it frmClientSearch) On this form i have a 2 list box thinghys; One called lstEmployee which is populated with Employee names and the other lstCity which is populated with City Names. Then i have a command button (cmdSearch) which, once click and values selected in both the lst boxes, should return only the values that are equal to both the lst boxes in a new form called frmSearchResult. (Hope i make sense) So... I know how ...

Inventory Valuation and Location Records
All: Its been awhile since I had to deploy Inventory so I need a quick refresher on Valuation Methods and their intersection with Location Codes. If I remember correctly, Average Perpetual tracks costs at the item level, with such average being applied across all sites. FIFO and LIFO (Periodic or Perpetual) all track at the Site and Item level. Is this correct? I tried to find this in the manual, but it is less than clear. Thanks, Dwight -- ...

MSCRM record count
I have a SQL query that searched my products based on a product number. My goal is to see if the product exists, and set a BOOL value accordingly. My code (listed below) does work, but it seems a bit inefficient for what I want to accomplish. I’m looking for the equivalent to a COUNT statement. Any suggestions? QueryExpression query = new QueryExpression(); query.EntityName = EntityName.product.ToString(); ColumnSet productColumns = new ColumnSet(); productColumns.Attributes = new string[] { "productnumber" }; query.ColumnSet = productColumns; ConditionExpression newConditi...

Search, Search, Thanks
In the last couple of weeks I have been fighting with different ways o synching my laptop and my home pc. I have ended up with numerou duplicate entries, duplicate address books and duplicate contact lists ALL of my questions/problems I was able to resolve simply by searchin through the forums. Chances are if you have a problem you're not th first. There are some really good people on these forums that know alo more about Outlook than I do. Just my .02 Thank ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages dir...

Edit last field without move to next record
How do I edit last field on the form without moving to next record after editing? On Fri, 15 Jun 2007 10:50:45 -0700, Song Su wrote: > How do I edit last field on the form without moving to next record after > editing? Try setting the Form's Cycle property to Current Record -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail ...

Including imap folders in outlook 2003 search folders
Dear all, Is it possible to include imap accounts/folders as providers for "virtual" search folders in outlook 2003? At the moment, I only see the option to check folders in my personal folders but not to include imap folders. The reason that I ask is that I would like to be able to get a complete view of follow up tasks across all my accounts (1 pop3, 2 imap and 1 hotmail). Only the pop3 account gets delivered into the personal folders and is included in the follow up a nd unread search folders. Thanks for your help in advanced. Raj ...

Display search results
Using OneNote 2010 Beta: file tabs are on the left; how can I make search result tabs appear on the right? Now they don't appear at all: the first search result is displayed in the middle of the screen (that's fine) but no way to move to the next search result, nor any way to scrool them all the search results. I'd like to see all the search result tabs listed on the right so I can choose the one I want (as was the case with the version of OneNote that got replaced by 2010 beta). Many thanks for any help. -- CH I can't really visualize what you want, but h...