Validating field values using an array

MS WORD

    Next

  • 1. selection.find question
    Hi, for selection.find, how can I search sth that start will the word "Chapter" If I use regexp, I can set pattern = "^Chapter" Can I use "^" in wildcards selection.find? Many Thanks
  • 2. Selection.Find
    I am attempting to find some text (which needs to be replaced). The macro used Selection.Find. Because the text is actually contained in a text box the macro does not find it. Is there any way of forcing the find to look in the text boxes as well (or select the text box before execution). Carl.
  • 3. Clear clipboard
    Hello everyon Could someone tell me how to clear the clipboard with VBA I'm using Word 2000 Thanks in advanc Simas
  • 4. Why can't I connect to Internet to download business cards?
    I keep getting the error message that I'm not connected to the internet when I am. Thanks for any help I can get.
  • 5. Add-in or component to access database or XML from MS-Word
    It is difficult to succinctly describe what I am looking for in the title of the post but a smart and simple solution may be obvious to some people here. I have a list of "requirements" arranged in a text document. They actually form a small hierarchy with about 2,3 or 4 levels roughly - I could represent this easily in XML. In Word I want to be able to quickly navigate to a particular "requirement" (simply a short sentence stating what is needed) and to be able to select the text and copy it into the Word document, i.e. I want a way to quickly compile a specification from these requirements. Is there a simply way to do this? I currently have to search through a few 100 pages and find the requirement that I'm looking for, then copy and paste it in to my specification - this is tedious and slow. I don't mind if I have to put the requirement data into XML or into Access or Excel I just need to speed the process up. Any suggestions? In addition, I first need to be able to search the list or database of requirements to find the appropriate requirement and then select it - the text will then be copied/inserted into my specification. Perhaps there is an add-in I can use, download, buy or write(I'm used to develop in C/C++ when I had a proper job!), one that operates like a tree control (from which you paste the selected text) and one that can be loaded with the text from an XML file. Is there such a component I can customise?

Validating field values using an array

Postby liz » Tue, 19 Jun 2007 00:10:01 GMT

The code below is sliced out of my latest efforts. I have a form with
some fields that are mandatory and ortehrs not. to test them I am
trying to use an array with the names of the mandatory fields. But it
will only ever report invalid even when it shold be OK. I#m sure it's
something simple that i can't see for looking. Can anyone spot the
problem?

'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'   Initialise the mandatory fields array etc.
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    valuesMandatoryFields() = Array _
        ("DocTitle", "DocSubject", "DocAuthor",
"DocPublicationStatus", "DocVersion", "DocType")
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'   Check each field
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    For Each conControl In Me.Controls
        If LCase(TypeName(conControl)) = "textbox" Then
            'strMsgInsert = conControl.Name                          '
debug
            'MsgBox "checking field " & strMsgInsert, vbOKOnly
                If IsFieldMandatory(conControl.Name) = True Then    '
it's a mandatory field
                    If Not Len(Trim(conControl.Text)) > 0 Then      '
and they haven't entered anything so
                        booEntryValid = False                       '
set flag so that returns to user
                    End If
                End If
        End If
    Next

'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'   Either exit to process valid or return invalid to user
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    If booEntryValid = True Then
        MsgBox "all Ok"
        Me.Hide                                                    '
valid entry so return control to calling module
    Else                                                            '
invalid entry ask them to try again
        MsgBox "You have not entered one or more of the mandatory
field please try again"
        DocTitle.SetFocus
'set focus to first field before returning control to user
    End If

The Function is like this:

Private Function IsFieldMandatory(varFieldToTest) As Boolean
    For Each varMandatoryField In valuesMandatoryFields
        IsFieldMandatory = (varMandatoryField = varFieldToTest)
    Next
End Function

thank you

luca


Re: Validating field values using an array

Postby Peter Jamieson » Tue, 19 Jun 2007 00:22:46 GMT

Do you set booEntryValid = True anywhere?

Peter Jamieson






Re: Validating field values using an array

Postby liz » Tue, 19 Jun 2007 04:53:35 GMT

On 17 Jun, 16:22, "Peter Jamieson" < XXXX@XXXXX.COM >





I thought I replied to this but obviously not... Yes immediatelt
before initialising the array, I also realise that I had said it is
always invalid, I should have said valid!


Re: Validating field values using an array

Postby liz » Tue, 19 Jun 2007 06:14:21 GMT

n 17 Jun, 20:53, XXXX@XXXXX.COM wrote:

I seem to have resolved this, although I'm not sure how!


Similar Threads:

1.return array value using excel automation function

I have three values that I need to return from an excel automation 
function written in C#.  I am successful reutrning single values of type 
string, double, int, ... from a COM automation function.  But I do not 
know how to return more than one value.

For example, I would like to be able to write a function such as

[First, Middle, Last] = getName( socialSecurityNumber )

where I have an automation function, getName, that takes a social 
security number and returns the three parts of a person's name.

Thanks,
Phil

2.Update a field using variables for the Field name and value

'Both the Fieldname(Array position= KPIParticulars(x, 9)) 
and the value(Array Position =KPIParticulars(x, 8)) I want 
to assign it are in an array called KPIParticulars()

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

rst.Open TblNm, CurrentProject.Connection, adOpenStatic, 
adLockOptimistic

With rst
    .AddNew
    !Date = DT    
    !KPIParticulars(x, 9) = KPIParticulars(x, 8) 
    '****here is my problem I tried a couple of 
    '****variations to no avail????
    .Update
End With

rst.Update
rst.Close
 

3.how to get selected field values into an array

Hi Everybody,

I have a database from where I want to extract some data matching the
requirement using SQL statement into an array.
To illustrate let the required field be A, B, and C.
The SQL statment be of sometype e.g.
sql= select A and B and C from "data.dat"

After placing the pointer at the top of the database file, can we
write

getdata=getrows()

to extract the required fields A, B and C?

Pl. help.

thanks

4.Validating checkbox values in MS Word

I have a form where I have multiple Yes/No checkboxes next to
questions.  The Yes/No checkboxes reside in a table and each checkbox
is in its own table cell.

What I want to do is not allow the user to check both checkboxes for
one question.

Can anyone help with what the code would look like?

Thanks so much!

5.Problem with validating checkbox values

I have a form where I have multiple Yes/No checkboxes next to
questions. The Yes/No checkboxes reside in a table and each checkbox
is in its own table cell.


What I want to do is not allow the user to check both checkboxes for
one question. I would like to do this in vba code. Here is what I have
so far. The issue is that if the user tabs between Yes/No fields it
checks the new field and unchecks the previous field.


Sub MakeCheckBoxesExclusive()
Dim oField As FormField
RowNum = Selection.Information(wdEndOfRangeRowNumber)
For Each oField In Selection.Tables(1).Rows(RowNum).Range.FormFields
oField.CheckBox.Value = False
Next oField
Selection.FormFields(1).CheckBox.Value = True
End Sub

6. trying to populate a combobox using values stored in an array

7. Using VBA - create array - parse values - find differences

8. using VB to read in a column of values of varying length into an array



Return to MS WORD

 

Who is online

Users browsing this forum: No registered users and 99 guest