Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 4th, 2010, 08:28 AM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Default Access, how to convert data type from text to number

Hi everyone, I need your help!

On my Access table Projects0, my field name IndexCode, data type is text. I try to use combo box and List box. combo box for IndexCode0, and List box for ProJe. I need to bound these two fields. When I select item from IndexCode0, the related item should show up on List box Proje, but I got "data type mismatch in criteria expression". Here is my code:

****

Private Sub IndexCode0_AfterUpdate()
Me.ProJe.RowSource = "select ProjectName from Projects0 where IndexCode=" & Me.IndexCode0

End Sub

**

If I swithch IndexCode data type from text to number, it works, but I can not. Because in this field, many data start with 0, like 00723, so I have to use data type text for IndexCode on table.

Thanks,

Cindy
 
Old October 4th, 2010, 11:26 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Try:

Code:
Private Sub IndexCode0_AfterUpdate()

Me.ProJe.RowSource = "select ProjectName from Projects0 where IndexCode=" & Chr(34) & Me.IndexCode0 & Chr(34)

End Sub
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
The Following User Says Thank You to HiTechCoach For This Useful Post:
cindyl (October 4th, 2010)
 
Old October 4th, 2010, 11:48 AM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Smile It works!

Quote:
Originally Posted by HiTechCoach View Post
Try:

Code:
Private Sub IndexCode0_AfterUpdate()

Me.ProJe.RowSource = "select ProjectName from Projects0 where IndexCode=" & Chr(34) & Me.IndexCode0 & Chr(34)

End Sub

Thank you so much, it works! You made my day!
Cindy
 
Old October 4th, 2010, 11:50 AM
Authorized User
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Thank you so much! You made my day!

Cindy
 
Old October 4th, 2010, 11:58 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

You're welcome!

Glad I could assist.

I also have lots of stuff on my site @ http://www.hitechcoach.com
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015





Similar Threads
Thread Thread Starter Forum Replies Last Post
Scale and Precision in number Data type code_lover Oracle 1 April 9th, 2009 04:56 PM
Why data-type="number" not working here... akentanaka XSLT 6 July 12th, 2008 07:13 PM
code of convert xml data type in string by C# prafullaborade XML 2 May 24th, 2008 07:49 AM
Convert Char Data Type to smalldatetime rylemer SQL Language 3 March 3rd, 2005 03:13 PM
casting textbox to sqlserver number data type yoord BOOK: Beginning ASP.NET 1.0 1 October 17th, 2004 06:09 AM





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