Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 11:15 AM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find Record Use Combo Box

Hi Expert,

I would like to use a combo box to find a record in a form. I met the error message of data type is mismatch. The field acct_no is in type of number -long integer so I use CLng() to convert text of combo box. Can you give me a help?

Me.RecordsetClone.FindFirst "[acct_no] = '" & CLng(Me.cbo_find.Value) & "'"
If Me.RecordsetClone.nomatch Then
    MsgBox Me.cbo_find & " Not Found"
Else
    Me.Bookmark = Me.RecordsetClone.Bookmark
End If

FYI. If I fix the account no and put Me.RecordsetClone.FindFirst "[acct_no] = 123456" then I can locate the record in form.

Thanks and Best Regards,
martinaccess :D:D:D

 
Old October 13th, 2004, 12:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Me.RecordsetClone.FindFirst "[acct_no] = " & Me![cbo_find]
Me.Bookmark = Me.RecordsetClone.Bookmark
cbo_find = Null

The above works for me with no conversion of the number (integer in my case)

Hope this helps.


Clive Astley
 
Old October 17th, 2004, 07:42 AM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Clive,

Thanks. Your code really works! But I find combo box has not stored any value but I want it to be. Would you know if the control source is blank, how can combo box display the selected option after running your codes?

Please help.

Thanks and Best Regards,
martinaccess :D:D:D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box can't find Object message PaulJH Access 5 April 13th, 2007 03:27 PM
Combo Box posting to Wrong Record alaxmen Access 1 February 3rd, 2006 12:56 PM
how to browse a record through a combo box shankar Access VBA 3 December 22nd, 2004 08:49 PM
Find Record Combo Box Wizard Won't Show 3rd Choice HenryE Access 0 February 2nd, 2004 11:52 PM
Combo box DisplayMember only shows on 1st record jraymond VB.NET 2002/2003 Basics 1 June 13th, 2003 09:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.