Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Code Modification

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sky Warren - 17 Mar 2005 20:18 GMT
Hello All,

I have a Combo box that looks up values in the Last Name field. It works
fine but it only BookMarks the first occurance of any matching criterior. My
Combo box has two columns "Last Name", "First Name". What I would like to do
is modify the code to force it to bookmark criterior based on both fields if
that's possible.

Here's the code for the Combo box:

Option Compare Database
Option Explicit
Const adhcQuote = """"

Private Sub cboFindLast_AfterUpdate()

   Dim rst As DAO.Recordset

   Set rst = Me.RecordsetClone
   
   rst.FindFirst "[Last Name] = " & _
       adhHandleQuotes(Me!cboFindLast, adhcQuote)
       
   If rst.NoMatch Then
       MsgBox "No match was found."
   Else
       Me.Bookmark = rst.Bookmark
   End If
   
   Set rst = Nothing
End Sub
Mark - 17 Mar 2005 20:48 GMT
Does your names table have a primary key field?  If not, you should add one;
for the purpose of looking up records, an autonumber would work fine as a
primary key.  Your combo box's row source should include this field (and be
bound to it).  You can hide this column so your users only see the lastname
and firstname.  Then when you do your search, you only need to look for an
integer value and you won't have to worry about any quotes in the search
string.  Since you'd be matching a primary key value, you will be assured of
matching the exact record that was selected in the combo box.

> Hello All,
>
[quoted text clipped - 30 lines]
>    Set rst = Nothing
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.