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 / May 2007

Tip: Looking for answers? Try searching our database.

FindFirst sticking with first record?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BonnieW - 07 May 2007 16:55 GMT
I have a combo box that queries from a table of people to get a list of names,
ordered lastname, firstname, peopleID.  There are several people in this list
that have the same last name, and no matter which person I choose with that
last name, Access chooses the first person with that last name.  

(So effectively, if I have Smith Jon 1, Smith Jane 8, Smith Harold 9074395,
it'll always stick with Smith Harold 9074395.)

The  VBA behind this is:
Private Sub Combo26_AfterUpdate()
   ' Find the record that matches the control.
   Dim rs As Object

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[LastName] = '" & Me![Combo26] & "'"
   If Not rs.EOF Then
       Me.Bookmark = rs.Bookmark
   End If
Rem         MsgBox "Check back later this is being improved!"
   DoCmd.GoToControl "Command28"
End Sub

Advice please?
ruralguy - 07 May 2007 17:22 GMT
You need to FindFirst by an ID number rather than the last name.  

>I have a combo box that queries from a table of people to get a list of names,
>ordered lastname, firstname, peopleID.  There are several people in this list
[quoted text clipped - 19 lines]
>
>Advice please?

Signature

HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

BonnieW - 07 May 2007 17:38 GMT
Wonderful!  Thanks!  I changed it up so that it's no longer referencing
LastName, but PeopleID.

Private Sub Combo26_AfterUpdate()
   ' Find the record that matches the control.
   Dim rs As Object

   Set rs = Me.Recordset.Clone
   rs.FindFirst "[PeopleID] = '" & Me![Combo26] & "'"
   If Not rs.EOF Then
       Me.Bookmark = rs.Bookmark
   End If
Rem         MsgBox "Check back later this is being improved!"
   DoCmd.GoToControl "Command28"

Now it's giving me error 3464: Data type mismatch in criteria expression.  I
assume that this means now that it's a number field, not a text field, I need
to get rid of some of the quotation marks- but I don't know which ones.

Sorry about my noobishness; this is not my code even in the slightest, nor
have I ever really had to deal with VBA til about a week ago. :(
>You need to FindFirst by an ID number rather than the last name.  
>
[quoted text clipped - 3 lines]
>>
>>Advice please?
ruralguy - 07 May 2007 17:48 GMT
Which column in the ComboBox has the PeopleID?  If it is the bound column
then you can just change this like to remove the quotes:

rs.FindFirst "[PeopleID] = " & Me.Combo26

If it is other than the bound column then you can use the column property:

rs.FindFirst "[PeopleID] = " & Me.Combo26.Column(2)

...for the 3rd column since the column index is zero based.

>Wonderful!  Thanks!  I changed it up so that it's no longer referencing
>LastName, but PeopleID.
[quoted text clipped - 22 lines]
>>>
>>>Advice please?

Signature

HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

BonnieW - 07 May 2007 17:52 GMT
It's the third column that holds the PeopleID.  The second code bit you
provided worked perfectly!  Thank you very much!

>Which column in the ComboBox has the PeopleID?  If it is the bound column
>then you can just change this like to remove the quotes:
[quoted text clipped - 12 lines]
>>>>
>>>>Advice please?
ruralguy - 07 May 2007 18:01 GMT
That's great Bonnie.  Glad I could help.

>It's the third column that holds the PeopleID.  The second code bit you
>provided worked perfectly!  Thank you very much!
[quoted text clipped - 4 lines]
>>>>>
>>>>>Advice please?

Signature

HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Susie Johnson - 08 May 2007 02:03 GMT
findFirst is a DAO method; and DAO has been depecrated

move to ADO and use a real FILTER method

> I have a combo box that queries from a table of people to get a list of names,
> ordered lastname, firstname, peopleID.  There are several people in this list
[quoted text clipped - 19 lines]
>
> Advice please?
ruralguy - 08 May 2007 02:24 GMT
I'm sorry but DAO has *not* been depreciated.  Where do you get this
information?

>findFirst is a DAO method; and DAO has been depecrated
>
[quoted text clipped - 5 lines]
>>
>> Advice please?

Signature

HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

 
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



©2009 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.