gonecoding
11-25-2016, 10:06 AM
Hello All,
On a userform I have 2 radio/option buttons ("No" and "Yes"), along with 2 textboxes ("FolderName" and "FileName"). I also have 2 command buttons ("Save & exit" and "Exit without saving").
If "Yes" is selected (checked on) then I would like to ensure that both of the textboxes have been filled-in, in order for the user to be able to successfully "Save & exit" the form. They should be allowed to select the "Exit without saving" button though.
What do I need to do in order to create the loop that will ensure that: as long as the "Yes" radio-button is selected, both foldername and filename values must be entered, in order to save and close the form?
I believe it might be something simple (and perhaps I've done this years back) but I just cannot remember how/what to do.
Here's the code that I have thus far:Code for the "Yes" radio-button clicked:
Code for the "Yes" radio-button clicked:
Private Sub optCreatePDFversionYES_Click()
Me.framePDFversionDetails.Enabled = True
Me.txtPDFversionFolderName.Enabled = True
Me.txtPDFversionFileName.Enabled = True
Me.lblPDFversionFolderName.Enabled = True
Me.lblPDFversionFileName.Enabled = True
End Sub
Code for the "Save & exit" command-button:
Private Sub cmdSaveAndExit_Click()
If Me.optCreatePDFversionYES.Value = True Then
If Me.txtPDFversionFolderName.Value = "" Or Me.txtPDFversionFileName.Value = "" Then
If Me.txtPDFversionFolderName.Value = "" Then
Beep
MsgBox "You must enter a folder name for the PDF file!", vbInformation, "Please note:"
Me.txtPDFversionFolderName.SetFocus
Else
Beep
MsgBox "You must enter a file name for the PDF file!", vbInformation, "Please note:"
Me.txtPDFversionFileName.SetFocus
End If
Exit Sub
End If
End If
End Sub
Thanks
On a userform I have 2 radio/option buttons ("No" and "Yes"), along with 2 textboxes ("FolderName" and "FileName"). I also have 2 command buttons ("Save & exit" and "Exit without saving").
If "Yes" is selected (checked on) then I would like to ensure that both of the textboxes have been filled-in, in order for the user to be able to successfully "Save & exit" the form. They should be allowed to select the "Exit without saving" button though.
What do I need to do in order to create the loop that will ensure that: as long as the "Yes" radio-button is selected, both foldername and filename values must be entered, in order to save and close the form?
I believe it might be something simple (and perhaps I've done this years back) but I just cannot remember how/what to do.
Here's the code that I have thus far:Code for the "Yes" radio-button clicked:
Code for the "Yes" radio-button clicked:
Private Sub optCreatePDFversionYES_Click()
Me.framePDFversionDetails.Enabled = True
Me.txtPDFversionFolderName.Enabled = True
Me.txtPDFversionFileName.Enabled = True
Me.lblPDFversionFolderName.Enabled = True
Me.lblPDFversionFileName.Enabled = True
End Sub
Code for the "Save & exit" command-button:
Private Sub cmdSaveAndExit_Click()
If Me.optCreatePDFversionYES.Value = True Then
If Me.txtPDFversionFolderName.Value = "" Or Me.txtPDFversionFileName.Value = "" Then
If Me.txtPDFversionFolderName.Value = "" Then
Beep
MsgBox "You must enter a folder name for the PDF file!", vbInformation, "Please note:"
Me.txtPDFversionFolderName.SetFocus
Else
Beep
MsgBox "You must enter a file name for the PDF file!", vbInformation, "Please note:"
Me.txtPDFversionFileName.SetFocus
End If
Exit Sub
End If
End If
End Sub
Thanks