473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VBA Len Counter when I go to a new record

31
I have a form where I have a text box counting the # of characters. I am using the following code:
Private Sub Goal1Comments_KeyDown(KeyCode As Integer, Shift As Integer)
'len counter for Goal 1 comments
Me.MaxNo1 = Len(Goal1Comments.Text)
In the form I have set the text box default value to "=Len([Goal1Comments])"

It works fine, but when I proceed to the next record, it keeps the # of characters from the first record. I want it to show the # that is on the new record.

Any help would be great.
Nov 17 '08 #1
7 2790
missinglinq
3,532 Expert 2GB
In the form I have set the text box default value to "=Len([Goal1Comments])"

It works fine, but when I proceed to the next record, it keeps the # of characters from the first record. I want it to show the # that is on the new record.
If you want each record to show the number of characters in ***its own Goal1Comments*** don't set the Default Value to anything, simply use the code you've got. The Default Value is designed to do exactly what it is doing, displaying the value that's assigned to it in the textbox when a new record is created.

Welcome to Bytes!

Linq ;0)>
Nov 17 '08 #2
apank
31
I should have send when I go to the next record it displays the len of the record I just updated. If the first record comments is "Red Sox" the len is 7. When I go to the next record which already says "NY Yankees" the len is 10 but the text box still shows 7 until I begin typing in the comments box. I want it to display 10 when I get to that record.
Nov 17 '08 #3
missinglinq
3,532 Expert 2GB
Remove the code assigning the Default Value.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Not IsNull(Me.Goal1Comments.Value) Then
  3.   Me.MaxNo1 = Len(Me.Goal1Comments.Value)
  4. Else
  5.   Me.MaxNo1 = 0
  6. End If
  7. End Sub
Linq ;0)>
Nov 17 '08 #4
apank
31
The counter is still not changing when I go to another record. It's usable, but not doing what I wanted which is to show the current len when the record is displayed in the form and when I type additional comments. If the field has existing date when you get the record, I need it to display that count. Your code makes sense, but it does not seem to get the desired affect.

Thank you by the way for taking your time to help me.
Nov 18 '08 #5
missinglinq
3,532 Expert 2GB
I don't know what else to tell you. The code is valid, assuming the names of the controls you posted are correct. Since your last post I ran up a form per your specs and it works as expected.

If you can zip up your file and post it here I'll be happy to look at it.

A quirk of this site is that you have to write a post, submit it, then immediately click on "Edit" then scroll down below the edit box to find the Attachment area.

Linq ;0)>
Nov 18 '08 #6
apank
31
You were right. I got it to work. I really appreciate your service. This site really is great.
Nov 18 '08 #7
missinglinq
3,532 Expert 2GB
Glad you got it working and glad we could help!

Linq ;0)>
Nov 18 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jim in Arizona | last post by:
I've been looking for a counting script to count the number of hits to my HTM and asp web pages on my company's internal website. So far, everything I've seen only works on asp pages. Where would I...
6
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything...
0
by: Earl Anderson | last post by:
KB Article Q140908 provided the following function to create an Auto Incrementing Counter: Function Next_Custom_Counter () On Error GoTo Next_Custom_Counter_Err Dim MyDB As Database Dim...
1
by: Dino Buljubasic | last post by:
Hi, I have to generate a number representing ID of my record in format like: 2004.00001 where 2004 is current year and 0000x is the number of record added to my database (i.e. 1st record is 00001,...
4
by: Ian Davies | last post by:
Hello I have seen some tutorials to put a update a counter field in a record. I have the counter field in a table that also has a field for a path to file. I display the records in a table on...
13
by: technocraze | last post by:
Hi guys, I have an issue with incrementing a counter in a table using VB in MS Acess environment. Below mentioned is an instance. Implementation logic Table fields Serialno = pk Datatype...
4
by: WEG | last post by:
I want to create a custom counter to act as the primary field in a table but am having trouble with it. What I would like is a counter that shows the last two digits of the year, a hyphen, then...
4
by: tedpottel | last post by:
Hi I'm trying to build a counter that will keep trach how many hits I got and where they came from. In my html pages I have a script of code that loads in an image. This image is a php file. ...
2
by: Sam | last post by:
Is there a formula or easy way to add a record counter in Access to a query? I have a field that contains a file number this file. I want to add a counter like below. Field Name Field...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.