VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



AllowZeroLength

by Killcrazy (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (39 Votes)

All fields in the selected table are processed and the AllowZeroLength property of the fields are set to either True or False, depending on the Status given as the finaal parameter The function returns a boolean value that can be used by the user to determin other operations.

Inputs
strDatabase = Full database path strTableName = Name of table to be processed Status : True / False
Code Returns
True/False

Rate AllowZeroLength

Function AllowZeroLength(strDatabase As String, strtablename As String, status As Boolean) As Boolean
Dim db As Database
Dim td As TableDef
Dim fd As Field
On Error GoTo Error_Handler
Set db = OpenDatabase(strDatabase)
Set td = db.TableDefs(strtablename)
  'loop through the fields in the selected recordset
  For Each fd In td.Fields
    'Check the field type, and only change the value of text and memo fields
    If fd.Type = dbText Or dbMemo Then
      If status = True Then
         fd.AllowZeroLength = True
      Else
        fd.AllowZeroLength = False
      End If
    End If
  Next fd
  
  AllowZeroLength = True
  ' Exit Early to avoid error handler.
  Exit Function
Error_Handler:
  ' Raise an error.
  Err.Raise Err.Number, "AllowZeroLength", "Could not process fields.", Err.Description
  AllowZeroLength = False
  
  ' Reset normal error checking.
  Resume Next 
  
End Function

Download this snippet    Add to My Saved Code

AllowZeroLength Comments

No comments have been posted about AllowZeroLength. Why not be the first to post a comment about AllowZeroLength.

Post your comment

Subject:
Message:
0/1000 characters