Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 January 23rd, 2004, 12:37 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default Data Types

Frist hello and thanks to all the people who look at these questions and give help. I enjoy this site, being new to access/vb coding. I hope someday to give back help to others once I become good at this.

Question: I have a column in a table which is a currency datatype. When the user is entering data via the form, and they get to this field, and they don't have an amount to enter or an amount doesn't pertain to this particluar record, I would like the field to default to "NA", which is text.

I don't think that is possible, but perhaps someone know's a way around that.
Thanks, BPH

 
Old January 23rd, 2004, 12:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Put an invisible label over your field with a caption of NA and when the currency field is null or meets your other conditions, make the label visible and the text box invisible. This will work for your form, but not in the table at which time you will probably need another field, possibly Yes/No field to denote whether it is applicable or not.

Regards,

Beth M
 
Old January 23rd, 2004, 01:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

What you do is not touch the table at all. If the value is null, so be it.

On the form, however, if the form is UNbound, then it's easy because you can populate the textbox with the actual amount (if not null) or you can populate the textbox with the string "N/A" if the actual amount is null. The datatype won't matter because the unbound textbox is not subject to a datatype. When it comes time to save the data back to the table, ignore the "N/A" and just let that value be null in the table.

If your form IS bound, then create an UNbound textbox and label it the same as the bound textbox with the currency amount. Make the bound textbox INvisible. Make the UNbound textbox visible. Then on the form's ON OPEN event you can put something like this, assuming that Me.txtMyAmount is the UNbound, visible textbox and Me.txtMyRealAmount is the bound, INvisible textbox, then

Me.txtMyAmount = Nz(Me.txtMyRealAmount,"N/A")

If you have currency, the visible textbox just shows it. If you don't have currency (the table value is null), the visible textbox will just show "N/A".


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old January 25th, 2004, 05:50 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Got it.
Used the bound and unbound method, only I put it in the 'On Current' Event. That allowed moving from record to record. Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
System Data Types liamfitz Beginning VB 6 0 October 17th, 2006 05:31 PM
Data Types Clive Astley Access 1 January 17th, 2006 04:13 PM
Data Types edward2006 Infopath 0 November 7th, 2005 06:06 PM
Data types in SQL SQ SQL Language 4 October 3rd, 2004 02:07 AM





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