Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2010, 08:28 AM
Authorized User
Points: 188, Level: 3
Points: 188, Level: 3 Points: 188, Level: 3 Points: 188, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old October 4th, 2010, 11:26 AM
Friend of Wrox
Points: 1,015, Level: 12
Points: 1,015, Level: 12 Points: 1,015, Level: 12 Points: 1,015, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
The Following User Says Thank You to HiTechCoach For This Useful Post:
cindyl (October 4th, 2010)
  #3 (permalink)  
Old October 4th, 2010, 11:48 AM
Authorized User
Points: 188, Level: 3
Points: 188, Level: 3 Points: 188, Level: 3 Points: 188, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #4 (permalink)  
Old October 4th, 2010, 11:50 AM
Authorized User
Points: 188, Level: 3
Points: 188, Level: 3 Points: 188, Level: 3 Points: 188, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Posts: 45
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Thank you so much! You made my day!

Cindy
Reply With Quote
  #5 (permalink)  
Old October 4th, 2010, 11:58 AM
Friend of Wrox
Points: 1,015, Level: 12
Points: 1,015, Level: 12 Points: 1,015, Level: 12 Points: 1,015, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.