Macro to set Field Value

jempie

Registered User.
Local time
Today, 02:55
Joined
Jul 28, 2004
Messages
34
I have a table named (say Table1), with two fields (say Field1 and Field2).

I am trying to create a macro that will set both Field1 and Field2 to Text with Field Size of 10.

Is this possible?

Regards,

Jempie
 
Why do you want to be able to do this? Why can't the values be set in the design of the table?
 
While there are many ways to skin a cat, this is one cat I rarely skin. Ever since the anti-vivesection league got after me, that is...

Dynamically changing a field type from ANY place is rather dangerous.

If the field is not populated, you MIGHT find a way to do it by tripping some code using a RunCode action that mucked about inside the tabledef.fields collection, changing the properties of the selected fields. The Access macro functionality doesn't normally extend to table redesign, so the macro would at most be the springboard for the described action.

BUT ... if the table is populated, you now have to worry about what happens if your soon-to-be-10-bytes-long field already contains 11 bytes when you try to do what you describe. You will have to handle multiple conversion errors, as a minimum. Plus who knows what else...?

You aren't the first person to ask questions about dynamic field alteration. In general, this is not a good idea only because Access, being rather ... simple-minded and literal-minded in its approach, will get confused that much more quickly.

Self-modifying code is a nice, powerful ability. Usually the nicest thing about this ability is the incomparable speed with which you can now make irrevocable mistakes that result in permanent data loss. Why do things by hand when you can automate the process? OK, I'm being a bit sarcastically ironic today. (Must be a phase-of-the-moon thing.) But seriously, any design that involves automated, even if infrequent, changes of data type makes me highly suspicious of the design.
 
the table is imported into access.

whenever it imports the table, although i can set the field to text, i cannot set the field length if the file is comma seperated.

I guess i will just have to stop trying to create shortcuts, and make sure that I do it manually!

Thanks for your help anyway guys.

Jempie
 

Users who are viewing this thread

Back
Top Bottom