Survey Form at SlipStick.com - data validation

K

K M

I found the Survey form at SlipStick.com very useful
(http://www.slipstick.com/files/survey.zip.), but it has a few
problems. I'm trying to fix them with what I thought would be some
very simple data validation and am getting frustrated.

On a 1-10 rating question, the user can enter values of -5, 3.2, and
30. If the question is a 1-10, then that range should be the only
range acceptable.

I haven't tackled the decimals yet, because I can't even get the range
to work. Here is what I have in the code:

Sub txtRate_Change()
If txtRate.Value<1 Or txtRate.Value>10 Then
msgResponse = MsgBox("Please enter a value between 1 and 10",
vbOKOnly)
txtRate.SetFocus
End If
End Sub

I cannot get data validation in the actual text box to work in design
mode, either. Can anyone point me in the right direction?
 
K

K M

Sue,

I appreciate the quick response.

A variation of that code is already in there. It is in the Item_Open()
function, as follows:

'Start snippet

Dim objControls
Set objControls = _
Item.GetInspector.ModifiedFormPages("Message").Controls


If Item.EntryID = "" Then
'irrelevant stuff ...
Else
'irrelevant stuff ...
Set txtRate = objControls("txtRate")

'End snippet

Just for fun, I tried putting your code in right after the "Else"
statement, and it also did not work. The form will still accept -3, 15,
etc.

What am I doing incorrectly?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

You would never put validation code in the Item_Open event handler, since
the user has not yet entered any information at that point to be validated.
It would need to go in the Item_Send event handler.

Also note: The newsgroup interface you are using apparently does not quote
earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please take
the time to quote the original message.
 
K

K M

You would never put validation code in the Item_Open event >handler,
since
the user has not yet entered any information at that point to >be validated.
It would need to go in the Item_Send event handler.

I am sorry that I was unclear.

I am not trying to put validation code int he Item_Open event handler.
Rather, I am trying to set up my form so I can use the Change event with
an unbound control (I hope I explained that correctly).

The code that you posted earlier:
set oPage = Item.GetInspector.ModifiedFormPages("name of page")
Set txtRate = oPage.Controls("txtRate")

was already in the form before I got it, in the Item_Open() event
handler. It was just a little different:

'Start Snippet
Dim objControls
Set objControls = _
Item.GetInspector.ModifiedFormPages("Message").Controls

If Item.EntryID = "" Then
'irrelevant stuff ...
Else
'irrelevant stuff ...
Set txtRate = objControls("txtRate")

'End snippet

What I am trying to do is, if a survey respondee is answering a "Rate
this from a scale of 1-10" question, they should have to type a value in
that range before moving to the next question. I could use the
Item_Send() handler, but that's not the most efficient way to do this,
as I would have to check the user's data on the back end, and not when
they're actually changing the data.
Also note: The newsgroup interface you are using apparently does not quote
earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please
take
the time to quote the original message.

Thank you for the tip, Sue. I am using a Web interface at work, as my
proxy does not allow direct USENET connections.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

Unbound controls do not fire a Change event. They fire a Click event -- but
not all controls do even that. (see
http://www.slipstick.com/dev/propsyntax.htm) Text controls are among those
that do not fire a Click event. This is why your validation code -- at least
that for text controls -- will need to go in Item_Send.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



See http://www.slipstick.com/dev/propsyntax.htm#unbound.
 
K

K M

Unbound controls do not fire a Change event. They fire a >Click event
-- but
not all controls do even that. (see
http://www.slipstick.com/dev/propsyntax.htm) Text controls >are among those
that do not fire a Click event. This is why your validation >code -- at least
that for text controls -- will need to go in Item_Send.

Again Sue, thanks for all of your help. One last question:

I've tried researching and can't find any answers. Since VBScript in
Outlook Forms has limitations compared to VBA or VB, is it possible to
create an Outlook Form in Visual Basic? If so, are there any
disadvantages to doing so?

I'm probably going to have to hand this survey form off to a programmer
who will customize it greatly, and who may not have a lot of time to
research VBScript limitations.

I appreciate (and have appreciated!) all of your advice.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

No, you cannot use VBA to create forms with the same functionality as
Outlook forms. Use VBA userforms for dialogs for VBA routines.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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