A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

select correct record



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2010, 02:59 AM posted to microsoft.public.access.forms
timbits35 via AccessMonster.com
external usenet poster
 
Posts: 20
Default select correct record

Hi,

I have an unbound box to search and select an athlete in a sales form. It
works only partially. Each athlete can have several sales records for each
contract year and there are some athletes with the same last name. I want to
be able to select the record based on the contract year. But when I try to
select the year that I want it just selects the first record. Here is my code
and the information from the recordsource box.

SELECT qrysales.Lname, qrysales.Fname, qrysales.SalesID, qrysales.
contractyear FROM qrysales ORDER BY qrysales.Lname;


Private Sub cbosearch_AfterUpdate()
' Find the record that matches the control.
On Error GoTo ProcError
Dim rs As Object

Set rs = Me.RecordsetClone
rs.FindFirst "[Lname] = '" & Me![cbosearch] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description
Resume ExitProc
End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201003/1

  #2  
Old March 1st, 2010, 01:01 PM posted to microsoft.public.access.forms
RonaldoOneNil
external usenet poster
 
Posts: 345
Default select correct record

rs.FindFirst "[Lname] = '" & Me![cbosearch] & "' And [contractyear] = " &
Me![cboSearch].Column(3)

"timbits35 via AccessMonster.com" wrote:

Hi,

I have an unbound box to search and select an athlete in a sales form. It
works only partially. Each athlete can have several sales records for each
contract year and there are some athletes with the same last name. I want to
be able to select the record based on the contract year. But when I try to
select the year that I want it just selects the first record. Here is my code
and the information from the recordsource box.

SELECT qrysales.Lname, qrysales.Fname, qrysales.SalesID, qrysales.
contractyear FROM qrysales ORDER BY qrysales.Lname;


Private Sub cbosearch_AfterUpdate()
' Find the record that matches the control.
On Error GoTo ProcError
Dim rs As Object

Set rs = Me.RecordsetClone
rs.FindFirst "[Lname] = '" & Me![cbosearch] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description
Resume ExitProc
End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201003/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.