Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls Underlying Field Size

Status
Not open for further replies.

GrantDB

Programmer
Jul 26, 2002
77
0
0
GB
Hi everyone,

I want to be able to find the size of a field that is linked to a textbox. For example, if the control, let's say a textbox, is named txt1 how can I find out the sizee of the field it is linked to.

I can find the field using - Me.txt1.ControlSource but then what?

Basically the user will be doing some copying and pasting and I want to do some validation before the text is pasted into the control.

Thanks in advance

Grant
 

fldSize=RecordsetClone("FieldName").Size

HTH
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
This will return the size in bytes of the field behind a control on a form.
It will only work if the form is bound to a table, because it uses TableDef for returning the Control source of the form.


Dim db As Database
Dim tbl As TableDef


Set db = CurrentDb
Set tbl = db.TableDefs(Me.RecordSource)
MsgBox tbl.Fields(Me.textboxname.ControlName).Size


db.Close
Set db = Nothing

There are two ways to write error-free programs; only the third one works.
 
I really don't see why you need to declare so many variables in this instance...
Without them, it works for any recordset, even a clone one [smile]

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Yep, I realised that when I saw your post, it's not something I'd actually done before and that was the first way I thought of.

[thumbsup2]to you.

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top