Combo Box Values in Custom Form

G

Guest

Here's the code that populates the comboboxes:

Set rst = db.OpenRecordset(projectScriptTable)
With rst
.MoveFirst

Do While Not .EOF

Set olPages = myItem.GetInspector.ModifiedFormPages
Set Ctrl =
olPages("Defects").Controls("TestScriptComboBox")
Set Ctrl2 =
olPages("Execution").Controls("TestScriptComboBox2")
Ctrl.AddItem ![ScriptName]
Ctrl2.AddItem ![ScriptName]
.MoveNext
Loop
End With
 
H

Hollis Paul

Set rst = db.OpenRecordset(projectScriptTable)
With rst
.MoveFirst

Do While Not .EOF

Set olPages = myItem.GetInspector.ModifiedFormPages
Set Ctrl =
olPages("Defects").Controls("TestScriptComboBox")
Set Ctrl2 =
olPages("Execution").Controls("TestScriptComboBox2")
Ctrl.AddItem ![ScriptName]
Ctrl2.AddItem ![ScriptName]
.MoveNext
Loop
End With
You really should restructure the code as follows:

Set rst = db.OpenRecordset(projectScriptTable)
With rst
.MoveFirst
Set olPages = myItem.GetInspector.ModifiedFormPages
Set Ctrl =
olPages("Defects").Controls("TestScriptComboBox")
Set Ctrl2 =
olPages("Execution").Controls("TestScriptComboBox2")

Do While Not .EOF

Ctrl.AddItem ![ScriptName]
Ctrl2.AddItem ![ScriptName]
.MoveNext
Loop

' Put code here to move the value in the controls to your UDFs!

End With
 
G

Guest

Sorry it's taken so long to reply, I've been swamped at work.

Okay, so this is probably where the problem lies. When you say ' Put code
here to move the value in the controls to your UDFs!' how do you do that? I
was under the impression that adding values to a UDF-bound control was all I
needed to do in order to preserve the data.


Hollis Paul said:
Set rst = db.OpenRecordset(projectScriptTable)
With rst
.MoveFirst

Do While Not .EOF

Set olPages = myItem.GetInspector.ModifiedFormPages
Set Ctrl =
olPages("Defects").Controls("TestScriptComboBox")
Set Ctrl2 =
olPages("Execution").Controls("TestScriptComboBox2")
Ctrl.AddItem ![ScriptName]
Ctrl2.AddItem ![ScriptName]
.MoveNext
Loop
End With
You really should restructure the code as follows:

Set rst = db.OpenRecordset(projectScriptTable)
With rst
.MoveFirst
Set olPages = myItem.GetInspector.ModifiedFormPages
Set Ctrl =
olPages("Defects").Controls("TestScriptComboBox")
Set Ctrl2 =
olPages("Execution").Controls("TestScriptComboBox2")

Do While Not .EOF

Ctrl.AddItem ![ScriptName]
Ctrl2.AddItem ![ScriptName]
.MoveNext
Loop

' Put code here to move the value in the controls to your UDFs!

End With
 
H

Hollis Paul

Okay, so this is probably where the problem lies. When you say ' Put code
here to move the value in the controls to your UDFs!' how do you do that? I
was under the impression that adding values to a UDF-bound control was all I
needed to do in order to preserve the data.
Your impression is probably true if you are using the GUI, in which the control
receives a click event. That does not happen when the values are added through
code.

How you move the value can be complicated. What you have in the control is an
array. I think that there is a Array or list property of the control that you
can use to move the value to the UDF. I am not sure what type of UDF you have
to have to receive it. You should search through the examples at
www.outlookcode.com for one that shows how to move the list property from a
listbox to a UDF.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top