PDA

View Full Version : Form's Drop or Scroll Boxes ~ HELP



GngrAmy
09-20-2007, 05:06 PM
I am trying to design a form in word. I need to make a few drop down sections or scroll bar for the Dx Coding part. I want to list all the Dx codes we use from the DSMIV, but the boxes, using them from the 'Forms tool Menu', it will only allow me to use 25 entries and I need at least 300. So I am trying to use the 'Control Form Tool Box'. I am having a hard time figuring it out. I believe I am using Office 2003

I haven't worked in Word in many years now so I am a bit lost and need some help through making this. May I please borrow someone through this?

Thank you,
Ginger

fumei
09-20-2007, 07:36 PM
Please try not to use jargon, or abbreviations that people may not understand.

I have absolutely NO idea what you are talking about re: "Dx codes", or "DSMIV".

DSMIV?
So I am trying to use the 'Control Form Tool Box'. I am having a hard time figuring it out.First of all....what have you tried?

Second of all, why do you want to have 300 listed items? That is way too many. People mention needing such huge numbers, but I have yet to see any example where that is actually true. There are ways to RE-item a list with a different list, depending on the first item selected.

I know if I saw a dropdown with 300 items listed I would refuse to use it.

In any case, ActiveX controls (from the Controls toolbox) are populated by code. You can do this from any code module, but the easiest is the ThisDocument module. Then you can use the control's name directly.Sub Document_Open()
Combobox1.Clear
Combobox1.AddItem "candy"
etc.If you are going to populate it with a lot of items, then you most likely will use an array. Say you have built an array of names (ClientName).Sub Document_Open()
Dim var
For var = 0 To Ubound(ClientName)
Combobox1.AddItem ClientName(var)
Combobox1.ListIndex = 0
Next
End SubThis would, on opening the document, populate the combobox with all the items in the array ClientName. It would display the first item in the list by default (ListIndex = 0). It is common to have the first item in the list notice text to the user. That is, the first item in the list could be: "Please select a name."

OTWarrior
09-21-2007, 02:31 AM
I have just fixed the 25 limit list on teh drop down form fields, here is the code, and a sample document of how it works.

(note, the code can be pasted into a document, it is dynamically coded so all you have to do is give each drop down form field a different bookmark name, and also make sure that aonentry and aonexit macros are chosen in each dropdown.)

btw, I would recommend using 2 step list select, ie: the drop down list (from an array) starts with group 1, group 2, then have a different array for each group, complete with an option to go back to the main list. I can generate a test example if you would like to know more.

Public BKMName As String
Public ResultCheck As String
Public nGenCount As Boolean
Public bprotected As Boolean
Public unHighlighted As Boolean
Public ffSelect As Word.FormField
Public ffSelectList As Word.ListEntries
Public ffSelectDropdown As Word.DropDown
Public HighlightSettings As Word.Range
Option Explicit

Public Sub AOnEntry()
Set HighlightSettings = Selection.Range
If Selection.FormFields.Count = 1 Then
'No textbox but a check- or listbox
BKMName = Selection.FormFields(1).Name
ResultCheck = ActiveDocument.FormFields(BKMName).Result
Call ffGenerator
Exit Sub
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
BKMName = Selection.Bookmarks(Selection.Bookmarks.Count).Name
ResultCheck = ActiveDocument.FormFields(BKMName).Result
Call ffGenerator
Exit Sub
Else
MsgBox "TOASTIE!!"
End If
ResultCheck = ffSelect.Result
Call ffGenerator
Exit Sub
End Sub
Public Function ffGenerator()
On Error GoTo ErrerHandel
Set ffSelect = ActiveDocument.FormFields(BKMName)
Set ffSelectDropdown = ffSelect.DropDown
Set ffSelectList = ffSelectDropdown.ListEntries
nGenCount = False


Dim Data As Variant
Data = Array("This", "Works", "Rather", "Well", "Wouldn't", "You", "Say?", "..Next List...")
Dim Data2 As Variant
Data2 = Array("Data1", "Data2", "Data3", "Data4", "...Previous List")

Dim i As Integer, i2 As Integer

If ffSelect.Result = "Select an Option" Then
Call unHighlighter
Exit Function

ElseIf ffSelect.Result = "..Next List..." Then

ffSelect.Select
With ffSelectList
.Clear
.Add "Select an Option"
Application.DisplayStatusBar = True
Application.StatusBar = "Please wait while Word rebuild the dropdown list..."
For i2 = LBound(Data2) To UBound(Data2)
.Add Data2(i2)
Next i2
End With
ffSelectDropdown.Value = 1
nGenCount = True

Application.DisplayStatusBar = False
Call Highlighter

DoEvents
SendKeys "%({DOWN})", True

Call ffGenerator
ElseIf ffSelect.Result = "...Previous List" Then


ffSelect.Select
With ffSelectList
.Clear
.Add "Select an Option"
Application.DisplayStatusBar = True
Application.StatusBar = "Please wait while Word rebuild the dropdown list..."
For i = LBound(Data) To UBound(Data)
.Add Data(i)
Next i
End With
ffSelectDropdown.Value = 1
nGenCount = True

Application.DisplayStatusBar = False

Call Highlighter

DoEvents
SendKeys "%({DOWN})", True

Call ffGenerator
Else
nGenCount = False

Call unHighlighter


End If
Exit Function
ErrerHandel:
MsgBox Err.Description, 64, Err.Number
Exit Function

End Function

Public Sub AOnExit()
Set ffSelect = ActiveDocument.FormFields(BKMName)
If nGenCount = True Then
Call Highlighter
Exit Sub
Else
If ffSelect.Result = "...Previous List" Then
Call ffGenerator
Exit Sub
ElseIf ffSelect.Result = "..Next List..." Then
Call ffGenerator
Exit Sub
Else
Call unHighlighter
Exit Sub
End If

End If
End Sub
Public Function Highlighter()
If ActiveDocument.ProtectionType <> wdNoProtection Then
bprotected = True
ActiveDocument.Unprotect Password:=""
End If

HighlightSettings.HighlightColorIndex = wdYellow
unHighlighted = False

If bprotected = True Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Function
Public Function unHighlighter()
If unHighlighted = True Then Exit Function
If ActiveDocument.ProtectionType <> wdNoProtection Then
bprotected = True
ActiveDocument.Unprotect Password:=""
End If
HighlightSettings.HighlightColorIndex = wdNoHighlight
unHighlighted = True

If bprotected = True Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Function

Try the example document, and let me know if you have any questions about it. Hopefully it has solved your problem.

GngrAmy
09-21-2007, 04:18 AM
Thank you for helping. I am not sure if I clearly understand everything that has been explained. I will work on it again this evening and over the weekend...

I will try and clear my codes I used:

DSMIV is a 'Bible' for Doctors, Therapists, Psychotherapists, etc...It is to help them give out the correct Diagnosis (Dx)

I am designing a form for when they receive a new client, the forms they fill out will already have the Dx code with the code's description in a drop down field, Or in some form of a field. The Dx codes range from 200 through 300.

Example of Dx Code:
308.3 Acute Stress Disorder
309.9 Adjustment Disorder Unspecified
309.24 Adjustment Disorder With Anxiety
296.8 Bipolar Disorder NOS
296.56 Bipolar I Disorder, Most Recent Episode Depressed, In Full Remission
296.5 Bipolar I Disorder, Most Recent Episode Depressed, In Partial Remission
296.51 Bipolar I Disorder, Most Recent Episode Depressed, Mild



I have four pages of Dx lists set up like this and I am trying to add all of them to a form field somehow with all the codes and descriptions.


Thank you again

OTWarrior
09-21-2007, 04:54 AM
I have redone the example document with some of your information.
Is this how you would want it to work?

NB: if you only wanted the Dx Code in the dropdown box, but the description in a textbox elsewhere, then use:

If ffSelect.Result = "308.3" then
activedocument.formfields("dxDescription").result = "Acute Stress Disorder "
else
'here you would do an elseif and put every variable to input into the result.
'you could do this calling from an array,
end if


you can change the if command to a case select to increase the speed of the code if you find the speed to be slow

GngrAmy
09-21-2007, 06:02 AM
That is perfect! I will have to review your notes closely and try this. It is my first time and I am not update with the correct coding and commands. I may be asking for more help.

Thank you

GngrAmy
09-21-2007, 07:42 AM
I am having a bit of hard time understanding how to put this together. This is all beyond me. It is perfect for what I need, but I think I am going to see what I can do in Excel. Thank you for you help

OTWarrior
09-21-2007, 08:01 AM
it is not the easiest code (took me 3 months on and off to fix all the bugs) but here are the main areas to focus on:

Dim Data2 As Variant
Data2 = Array("Data1", "Data2", "Data3", "Data4", "...Previous List")

Dim i As Integer


the sections in "" are each item you want in your list.
i is the count to make sure the loop works correctly

ElseIf ffSelect.Result = "..Next List..." Then

ffSelect.Select
With ffSelectList
.Clear
.Add "Select an Option"
Application.DisplayStatusBar = True
Application.StatusBar = "Please wait while Word rebuild the dropdown list..."
For i2 = LBound(Data2) To UBound(Data2)
.Add Data2(i2)
Next i2
End With
ffSelectDropdown.Value = 1
nGenCount = True

Application.DisplayStatusBar = False
Call Highlighter

DoEvents
SendKeys "%({DOWN})", True
Call ffGenerator

change "..Next List..." to what value you want to change it to (eg: "305 -310") and change the data2 and i in that section to what your new name for your array is. Chnage the i to whatever you have called i (it doesn't matter what name, so long as each one is unique in each loop.

hopefully, that is a bit more clearer for you.

GngrAmy
09-21-2007, 08:50 AM
I understand a few parts, then I get lost in others. Maybe when I have more time I will come back to this. I would love to know how to do this correctly.

I am going to see how it will work in excel...if it doesn't work then the doc's can refer to the DSM book themselves and type in their own Dx code...

Thanks again for your help

fumei
09-21-2007, 09:35 AM
I have just fixed the 25 limit list on teh drop down form fields,"fixed"? Ummm, not really. You did what I said could be done.


Second of all, why do you want to have 300 listed items? That is way too many. People mention needing such huge numbers, but I have yet to see any example where that is actually true. There are ways to RE-item a list with a different list, depending on the first item selected.

OTWarrior
09-24-2007, 01:07 AM
"fixed"? Ummm, not really. You did what I said could be done.

Yours was using a combobox, mine was using a dropdown form field. Not the same (but the same idea, which I had posted about previously)

Well...I have spent the past 3 months trying to get the full functionality to work by regenerating the list and making it automatically drop down when the list is regenerated, and no one on any forums that I had been on knew of a way to do this. All they suggested was to use multiple drop down boxes, or a userform.

Sure people said you could clear the list and add items back, but nobody I spoke to said you could cycle the lists depending on theh selection. I have yet to see someone else's code which works just like mine.

So yes, I would like to think that I have "fixed" the problem.

fumei
09-24-2007, 08:09 AM
True, I did mention combobox. That was in response to the OP. If I may quote:

So I am trying to use the 'Control Form Tool Box'.Which means....ummmm, combobox.

In fact, OTWarrior, I was thinking of EXACTLY your posts, and was going to refer the OP to them.

Further:
[Sure people said you could clear the list and add items back, but nobody I spoke to said you could cycle the lists depending on theh selection.Not true at all. I have posted how to do this - with examples - two years ago.

The difference is that you wanted to RESELECT the formfield. That, I agree was difficult, and you have come up with a solution. You are to be commended for that.

However, relisting a formfield dropdown based on a user selection has been posted before. You did NOT "fix" that.

Nor did you "fix" the issue of the 25 limit. Sorry, but your formfields still have a 25 limit.

What you did - and again I do commend you on it - was relisting AND going back to the relisted formfield and dropping it down.

But the relisting has been done before, and posted.

fumei
09-24-2007, 08:17 AM
I also wish to add, that even WITH your solution (and a good one it is), the OP still has to do what I mentioned.

That is, find a logic solution to breaking up the 300 items into meaningful chunks that can be displayed within the 25 limit of a formfield.

If they really, really, do want to list 300 items....your solution is of no use to them. The formfields have a 25 item limit.

If you read my post, I mentioned my opinion (just my opinion) that 300 items is too much for ANY dropdown, and that There are ways to RE-item a list with a different list, depending on the first item selected;

but that (in response to the OP direct question on Controls)....

"In any case, ActiveX controls (from the Controls toolbox).... "

OTWarrior
09-25-2007, 12:20 AM
GngrAmy did start off by saying:

but the boxes, using them from the 'Forms tool Menu', it will only allow me to use 25 entries and I need at least 300.

So I thought they would ideally want it in this format, not in activeX, that's all.

I am sure the relisting has been done before (it's two lines of code to clear the list and add one value) But I have seen it used to change another drop down form field rather than the currently selected one.

I know it is not a true fix to the 25 limit, but it is like putting tape on a broken chair leg. Sure, it is not how people would like it, but it works :thumb

And I do agree that 300 is a rather large list of items to select, and you would most likely have to have a 3 or 4 step system to get to the specific option required.

I can't think of a better solution with a drop down box (of any kind), other than just allowing the user to type whatever "dxcode" number they want into a text box, and to have another text box automatically generate a description based on the number.