B
Becki
Hi,
I have a Word 2007 form with 28 individual text fields where a user
must enter valid numbers. I found a post in this group with code that
was similar to what I wanted to do and am trying to modify it without
much success. I'm very new at this and any help would be very much
appreciated! Thanks in advance.
~ Becki
What I'm attempting to do:
When the user clicks on the 'Calculate' button, loop through the 28
fields, named 'TextBox1' through 'TextBox28' and edit them to make
sure they are numeric. If it finds one that isn't tell the user via a
message box and place the cursor in that field.
The problem:
I'm getting an error 424 - Object required on the statement 'Set fldFF
= TextFileName'
The code:
' Define public variables
Public fldFF As Word.FormField
Sub GoBacktoFF()
' ActiveDocument.Bookmarks("TextBox1").Result.Select ' Commented
out for now; change to use fldFF?
End Sub
Sub CalcButton1_Click()
' Make sure the hours entered are numeric
Dim TextFieldIndexInteger, MaxIndexInteger As Integer
Dim TextFieldName As Variant
TextFieldIndexInteger = 1
MaxIndexInteger = 28
Do Until TextFieldIndexInteger > MaxIndexInteger
TextFieldName = CVar("TextBox" & TextFieldIndexInteger)
Set fldFF = TextFieldName
With fldFF
If Not IsNumeric(fldFF.Result) Then
Application.OnTime When:=Now + TimeValue("00:00:01"),
_
Name:="GoBacktoFF"
Msg = MsgBox("Enter a valid number", 0, "Part II:
Estimate the Activities")
End If
End With
TextFieldIndexInteger = TextFieldIndexInteger + 1
Loop
I have a Word 2007 form with 28 individual text fields where a user
must enter valid numbers. I found a post in this group with code that
was similar to what I wanted to do and am trying to modify it without
much success. I'm very new at this and any help would be very much
appreciated! Thanks in advance.
~ Becki
What I'm attempting to do:
When the user clicks on the 'Calculate' button, loop through the 28
fields, named 'TextBox1' through 'TextBox28' and edit them to make
sure they are numeric. If it finds one that isn't tell the user via a
message box and place the cursor in that field.
The problem:
I'm getting an error 424 - Object required on the statement 'Set fldFF
= TextFileName'
The code:
' Define public variables
Public fldFF As Word.FormField
Sub GoBacktoFF()
' ActiveDocument.Bookmarks("TextBox1").Result.Select ' Commented
out for now; change to use fldFF?
End Sub
Sub CalcButton1_Click()
' Make sure the hours entered are numeric
Dim TextFieldIndexInteger, MaxIndexInteger As Integer
Dim TextFieldName As Variant
TextFieldIndexInteger = 1
MaxIndexInteger = 28
Do Until TextFieldIndexInteger > MaxIndexInteger
TextFieldName = CVar("TextBox" & TextFieldIndexInteger)
Set fldFF = TextFieldName
With fldFF
If Not IsNumeric(fldFF.Result) Then
Application.OnTime When:=Now + TimeValue("00:00:01"),
_
Name:="GoBacktoFF"
Msg = MsgBox("Enter a valid number", 0, "Part II:
Estimate the Activities")
End If
End With
TextFieldIndexInteger = TextFieldIndexInteger + 1
Loop