Aug 4 2010, 06:13 PM
Hi I am new to access. I need to create a blank field that contains 177 zeros. How do I do this. Can I set it as my default value and if so how?
Aug 4 2010, 06:25 PM
Welcome to UtterAccess.
At the risk of seeming condescending, why do you want a field with 177 zeroes in it? Is there some meaning to the fact that there are 177 zeroes? Are you trying to cram 177 different pieces of information into a single field?
While it's likely possible to do what you're trying to do, it sounds as though it's a bad idea to me. I'd strongly recommend you explain what you're trying to do, and one of us can suggest an appropriate way to achieve that end.
Aug 4 2010, 06:32 PM
Welcome to UtterAccess.
That's a very unusual requirement. But padding a field with zeroes, in itself, is not so hard. What I'm really curious about is this: "set it as my default value "
You can easily set the default value property of a field in that field's Default Propery on the property sheet. However, that implies the field is in a table, and you mention no tables. So, it might be good to start by telling us WHERE this field will live.
And BTW, there is a very distinct difference between a "blank field" and a field that contains 0's regardless of how many there are.
In short, if setting the default value for a field in a table isn't going to meet your requirement, please tell us what the goal is so we can try to give you some more usefull information and suggestions.
Aug 4 2010, 06:42 PM
I am sorry I meant to say I need to pad the field with 177 spaces not zeros. I need to prohibit people from entrying any data in that field.
Sorry for the confusion, this is all new to me.
Aug 4 2010, 06:59 PM
Here is a VBA function that inserts X number of spaces.
Returns a Variant (String) consisting of the specified number of spaces.
The required number argument is the number of spaces you want in the string.
The Space function is useful for formatting output and clearing data in fixed-length strings.
That might be what you want, but where and how you'll use it depends on the answer to Pad "what"?
Aug 5 2010, 04:04 AM
>> I need to prohibit people from entrying any data in that field <<
Padding a field with spaces will not prevent this. As soon as the user tabs into the control bound to field in question, typically the entire value is hilited --- one keystroke will delete the entry and the value will begin to reflect what the user is typing. Or, if that scenario does not pan out, the user can simply hit the delete key while in the control bound to the field in question.
The best way to prevent the user from entering data into a control bound to a field is by setting the controls Locked property to True.
Aug 5 2010, 08:00 AM
Let me start over. This is my problem.
Our Charter school has to submit data to the state. The requirement for this record is that in positions 1-23 we will have to input our data and in positions 24-200 they want it blank (pad with spaces). So how do I append these blanks to my record so that when we submit this record it has these blank spaces at the end.
I hope this help to clarify want I am trying to accomplish.
Aug 5 2010, 08:36 AM
"... submit data to the State ..."
Instead of storing "nothing" and then sending it, you could store only what YOU need, then use a query to add in the spaces. You could export the query (actually, the query's data).
Aug 5 2010, 08:47 AM
In other words, your query should have Left([SomeField], 23) & Space(177) rather than [SomeField]
Aug 5 2010, 09:37 AM
To add on to Doug's post...
In your output query (that you need to export to a text file) you should use this:
Left(Left([SomeField],23) & Space(200),200)
This will handle cases where your data is less than 23 characters wide, but will also limit your data to only 23 characters of the 200.
Aug 5 2010, 11:20 AM
Adding to the many fine reply's, I would advise you to set your field size to 23 for the field you wish to limit to 23 characters. Then here is yet another expression:
Left([SomeField] & Space(200),200)
Which is esentially just like Daryl S's, but there is really no need for the nexted Left() functions when you limit your input field to a size of 23.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here