disable Submit button

W

Worsty

In my word form which I am using all form fields with the exception of
a submit button. I'd like to know if there is a way to "disable" a
button (submit for ex:) until a specific criteria is met.

So basically, if activedocument.formfield("tesxt1").result = "ready to
submit" then
.....submit button.enabled = true else
......submit button. enabled = false

can someone help me out with the commandbutton reference code.

Thanks much!
 
F

Fumei2 via OfficeKB.com

Assuming the commandbutton is an ActiveX control, you simply have to exit its
Click event, like this:

Option Explicit

Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result = "" Then
MsgBox "Formfield is blank!"
Exit Sub
Else
MsgBox ActiveDocument.FormFields("Text1").Result
" or whatever else you are doing
End If
End Sub
 
F

Fumei2 via OfficeKB.com

Or, to be more specific to your request...

Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result <> "ready to submit" Then
MsgBox "Invalid input in formfield!"
Exit Sub
Else
MsgBox ActiveDocument.FormFields("Text1").Result
" or whatever else you are doing
End If
End Sub

Although, it does seem a little odd to put "ready to submit" into a text
formfield in order to execute a commandbutton.
Assuming the commandbutton is an ActiveX control, you simply have to exit its
Click event, like this:

Option Explicit

Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result = "" Then
MsgBox "Formfield is blank!"
Exit Sub
Else
MsgBox ActiveDocument.FormFields("Text1").Result
" or whatever else you are doing
End If
End Sub
In my word form which I am using all form fields with the exception of
a submit button. I'd like to know if there is a way to "disable" a
[quoted text clipped - 8 lines]
Thanks much!
 
W

Worsty

Or, to be more specific to your request...

Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result <> "ready to submit" Then
   MsgBox "Invalid input in formfield!"
   Exit Sub
Else
   MsgBox ActiveDocument.FormFields("Text1").Result
   " or whatever else you are doing
End If
End Sub

Although, it does seem a little odd to put "ready to submit" into a text
formfield in order to execute a commandbutton.




Assuming the commandbutton is an ActiveX control, you simply have to exit its
Click event, like this:
Option Explicit
Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result = "" Then
  MsgBox "Formfield is blank!"
  Exit Sub
Else
  MsgBox ActiveDocument.FormFields("Text1").Result
  " or whatever else you are doing
End If
End Sub
In my word form which I am using all form fields with the exception of
a submit button.  I'd like to know if there is a way to "disable" a
[quoted text clipped - 8 lines]
Thanks much!

***************************************************

Thanks for your reply.

I was Just using the text to fill in the result with something.

What I want to do is "disable" the commandbutton1. Is there a way to
do this?
 
K

kennkh

Depending on what your Word Object is named (You should have a list in your
project window under Microsoft Word Objects), it should look something like:

ThisDocument.submitbutton.enabled = true

If your button exists in ThisDocument

Worsty said:
Or, to be more specific to your request...

Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result <> "ready to submit" Then
MsgBox "Invalid input in formfield!"
Exit Sub
Else
MsgBox ActiveDocument.FormFields("Text1").Result
" or whatever else you are doing
End If
End Sub

Although, it does seem a little odd to put "ready to submit" into a text
formfield in order to execute a commandbutton.




Assuming the commandbutton is an ActiveX control, you simply have to exit its
Click event, like this:
Option Explicit
Private Sub CommandButton1_Click()
If ActiveDocument.FormFields("Text1").Result = "" Then
MsgBox "Formfield is blank!"
Exit Sub
Else
MsgBox ActiveDocument.FormFields("Text1").Result
" or whatever else you are doing
End If
End Sub
In my word form which I am using all form fields with the exception of
a submit button. I'd like to know if there is a way to "disable" a
[quoted text clipped - 8 lines]
Thanks much!

***************************************************

Thanks for your reply.

I was Just using the text to fill in the result with something.

What I want to do is "disable" the commandbutton1. Is there a way to
do this?
.
 
F

Fumei2 via OfficeKB.com

The following MUST be in the ThisDocument code module. Use it as the OnExit
macro for the formfield "Test1".

Sub Test1ExitMacro()
If ActiveDocument.FormFields("Test1").Result <> _
"Ready to submit" Then
CommandButton1.Enable = False
End If
End Sub

Although I still think it is very odd to do this. The chance of error seems
high. At the very least use a DropDown so they can select a "Ready to
submit" rather than having to type it in a textbox. Remember, ANY error at
all will disable the commandbutton. What if they inadvertantly put an extra
space at the end: "Ready to submit "; or an extra space between the words:
"Ready to submit"; or any possible spelling error; "Ready to suvmit"

Depending on what your Word Object is named (You should have a list in your
project window under Microsoft Word Objects), it should look something like:

ThisDocument.submitbutton.enabled = true

If your button exists in ThisDocument
[quoted text clipped - 46 lines]
do this?
.
 

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