Hello
I'm a newbie with VBA who needs your help.
I have created a userform that has several textboxs within it and an OK-button.
In the OK-button I have the following code:
Private Sub cmdOK_Click()
If ValidateData = True Then
SaveDataToWorksheet
ClearForm
Me.Hide
End If
End Sub
The problem I'm having is with the Validate-function, see code below:
Public Function ValidateData() As Boolean
If txtProductName.Value = "" Then
MsgBox "Please enter a product name."
ValidateData = False
Exit Function
End If
ValidateData = True
End Function
I have only pasted 1 If in the validate function here since the problem is the same for them all, and that is that even if the textbox txtProductName containing for example "Coca Cola", I still get the msgbox "please enter a product name".
What am I doing wrong? I seems to me that the variable ValidateData never get True but I do not understand why.
Thank you for your help, and a great forum.
Bookmarks