p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Data Types (http://p2p.wrox.com/showthread.php?t=8514)

bph January 23rd, 2004 12:37 PM

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


BethMoffitt January 23rd, 2004 12:47 PM

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

SerranoG January 23rd, 2004 01:23 PM

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

bph January 25th, 2004 05:50 PM

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.



All times are GMT -4. The time now is 12:24 AM.

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