Error when using dropdown

D

Dinsdale

Hi Everyone,

I have created several templates, some of which import blocks of text
and fields from master documents. In one instance, I am importing a
table containing fields (one being a dropdown) which takes the form of
an invoice. All the fields are calculating correctly except the invoice
line item dropdown. On the original, it works fine - once imported it
stops working. I have created the following code which generates Error
4241: Object required.

Dim UnitPrice1

Select Case LinePrice2
Case UnitPrice1.Value = 25.5
LinePrice2 = Qty1 * 25.5
Case UnitPrice1.Value = 32
LinePrice2 = Qty1 * 32
Case UnitPrice1.Value = 120
LinePrice2 = Qty1 * 120
End Select
 
J

Jezebel

That's not how to use Select Case. The idea of select case is to evaluate
the argument (in this case LinePrice2) against a set of comparison
functions. So what you are currently doing is equivalent to

If LinePrice2 = (UnitPrice1.Value = 25.5) then ...

Presumably there is code omitted between the declaration and the select
case; but the error implies that either you are not setting UnitPrice1 to an
object, or that object doesn't have a .Value property. The curse of the
variant!
 
D

Dinsdale

Jezebel said:
That's not how to use Select Case. The idea of select case is to evaluate
the argument (in this case LinePrice2) against a set of comparison
functions. So what you are currently doing is equivalent to

If LinePrice2 = (UnitPrice1.Value = 25.5) then ...

Presumably there is code omitted between the declaration and the select
case; but the error implies that either you are not setting UnitPrice1 to an
object, or that object doesn't have a .Value property. The curse of the
variant!
Mmm. Thanks. Wondered if I should be using if then instead.

Andrew
 
D

Dinsdale

Jezebel said:
Probably. But what is the UnitPrice1 object?
And I've fixed it:) Changed to using ActiveDocument.Formfields to
specifically refer to the field and now it all works.

Thanks for your help.

Andrew
 

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