Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

Count Textbox Characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tru - 15 Apr 2005 15:50 GMT
Is there any way I can count the charaters in a memo field including spaces.
I currently use the following procedure.

On Error GoTo Err_Form_BeforeUpdate
 If Len(Me![Notes]) > 1560 Then
   MsgBox "Your notes must be less than 1,560 characters.", vbInformation,
"Exceeded Field Limit"
   Cancel = True
 End If

Exit_Form_BeforeUpdate:
 Exit Sub

Err_Form_BeforeUpdate:
 MsgBox Err.Description
 Resume Exit_Form_BeforeUpdate

I want the user to have the ability to check the count before trying to save
the record.
Signature

Thanx!

Brendan Reynolds - 15 Apr 2005 15:57 GMT
Just copy your existing If ... End If code (minus the 'Cancel = True' line)
to the Click event procedure of a command button.

Signature

Brendan Reynolds (MVP)

> Is there any way I can count the charaters in a memo field including
> spaces.
[quoted text clipped - 17 lines]
> save
> the record.
Graham R Seach - 15 Apr 2005 16:04 GMT
What you've done is OK, but I'd be inclined to use the Change() event, so
the users know exactly when they have exceeded the limit. After all, your
users are going to be real amused when you finally tell them that you're
going to discard the last 500 (excess) characters they've just entered.
Better to let them know early, in my opinion.

Private Sub Notes_Change()
   If Len(Me.Notes.Text) > 1560 Then
       DoCmd.Beep
       'You can also put the MsgBox here if you must
       Me.Notes.Text = Left(Me.Notes, 1560)
   End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

> Is there any way I can count the charaters in a memo field including
> spaces.
[quoted text clipped - 17 lines]
> save
> the record.
Tru - 15 Apr 2005 16:16 GMT
You know what your absolutely right it happened to me already Thanx fellows I
really apprecite the help.

> What you've done is OK, but I'd be inclined to use the Change() event, so
> the users know exactly when they have exceeded the limit. After all, your
[quoted text clipped - 37 lines]
> > save
> > the record.
Klatuu - 15 Apr 2005 16:17 GMT
Change Event????
The change event fires after every character is entered.

> What you've done is OK, but I'd be inclined to use the Change() event, so
> the users know exactly when they have exceeded the limit. After all, your
[quoted text clipped - 37 lines]
> > save
> > the record.
Graham R Seach - 15 Apr 2005 16:41 GMT
...barada nicto.

<<The change event fires after every character is entered>>
That's right!

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

> Change Event????
> The change event fires after every character is entered.
[quoted text clipped - 41 lines]
>> > save
>> > the record.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.