counting all textboxes

alaric

Registered User.
Local time
Today, 15:49
Joined
Sep 6, 2004
Messages
50
Hi

im trying to figure out whats best to make my Cancel button aktive.
CAncel can only be used if something is really changed (otherwise access gives me an error)
So i thought of following:
count all fields an if it the number changes... aktivate the cancel button

so far I have

Dim strText As String
Dim strString As String
Dim lngAantal As Long
Dim cnt As Byte
Dim lngTotaal As Long
Dim strInhoud As String

lngTotaal = 0
For cnt = 1 To 14
lngAantal = 0
strText = "txtAdr" & cnt
strInhoud = Nz(Me.Controls(strText), 0)
If strInhoud = 0 Then
lngAantal = Len(strInhoud) - 1
Else
lngAantal = Len(strInhoud)
End If

lngTotaal = lngTotaal + lngAantal
Text116 = lngTotaal
Next cnt​

it works fine until a textbox is empty...
It must be easy but right now I cant figure out. What am I missing.
it errors ofcourse in this part --> strInhoud = 0

anyone suggestions?

thx
Al
 
I think the problem is that the control might contain a zero length string "" in stead of being Null, which the NZ function can't trap. You may try for instance this test:

if trim$(Me.Controls(strText) & "") = "" then
strInhoud = "0"
else
strInhoud = Me.Controls(strText)
end if

Or you could try
strInhoud = Nz(Me.Controls(strText), "")

since you're assigning to a string.
 
thx,

strInhoud = Nz(Me.Controls(strText), "")
did the job!


Al
 

Users who are viewing this thread

Back
Top Bottom