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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I determine a field size in MS Access using ASP

Status
Not open for further replies.

WartookMan

Technical User
Nov 24, 2003
346
AU
I have searched Google. I have searched multiple groups on Tek-Tips... but without success. I even posted to the MS Access Forum and they referred me to the ASP Forum.

Using ASP and an MS-Access database, I would like to retrieve a field's "Field Size" property. Is this possible? I want to be able to use it as a first-line trap for input validation, to set the "MAXLENGTH" attribute of an INPUT field on an HTML form.

I have managed to access a field's "Description" Property, and whether it can be Nullable (ie required) or not, but not it's size. I have even tried outputting ALL Properties for all Fields for all Tables available, but there doesn't seem to be a Property for the size!

This was my code for all the Properties available:
Code:
Dim objTable, objColumn, objProp
For Each objTable in objADOXDatabase.Tables
    If objTable.Type = "TABLE" then 
        Response.Write objTable.Name & "<br>"

        For Each objColumn in objTable.Columns
            Response.Write "&nbsp;&nbsp;&nbsp;" & objColumn.Name  & " - " & objColumn.Attributes & "<br>"
            
            For Each objProp in objColumn.Properties
                Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & objProp.Name & " - " & objProp.Value & " - " & objProp.Attributes & "<br>"
            Next
        Next

    Response.Write "<p>"
  End If
Next
Ultimately I'd like to create something like:
Code:
...
	<tr>
		<td>
		<label for="<%= fldID %>" class="normal" id="lbl_<%= fldID %>"><%= fldLabel %></label>:&nbsp;</td>
		<td><%
	If Not fldNotReqd Then
		%><span class="fld_reqd">*</span><%
	End If
	%></td>
		<td><input type="text" maxsize="<%= fldSize %>" size="20" id="<%= fldID %>" name="<%= fldID %>"></td>
	</tr>
...
where:
fldID - field's "Name" property in Access
fldLabel - field's "Description" property
fldNotReqd - field's "Nullable" property
fldSize - field's "Field Size" property
Any help / ideas would be most appreciated.

Pete.

Web Developer & Aptrix / IBM Lotus Workplace Web Content Management (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
If you were using ADO to query the table (I can't tell what objects your using from your code..?) then you could use fieldName.DefinedSize
ADO Field Reference:
-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top