caringsharingbristolbilly
Board Regular
- Joined
- Mar 23, 2004
- Messages
- 241
Hi guys.
I don't know what's going wrong with this. I've been toying with it for a few days, and can't figure it out. It's the first bit of code which I'm struggling with.
I want it to first look at the ProductType box, and if it hasn't changed from the default, to prompt the user to enter a valid choice.
Then I want it to go through all the mandatory required fields on the form and check that they all have values in, and again alert them if any are missing (I've only done the FirstName field so far, but I need to do about 8).
It does the first bit okay, warning people about the ProductType , but if the ProductType entry is okay, but the first name is missing, I don't get a message box, it just carries on with the rest of the code.
Could someone a little more experienced than me suggest where I'm going wrong? I'm very new to VBA, so I might have done it fairly clumsily...
Any help greatly appreciated...
I don't know what's going wrong with this. I've been toying with it for a few days, and can't figure it out. It's the first bit of code which I'm struggling with.
I want it to first look at the ProductType box, and if it hasn't changed from the default, to prompt the user to enter a valid choice.
Then I want it to go through all the mandatory required fields on the form and check that they all have values in, and again alert them if any are missing (I've only done the FirstName field so far, but I need to do about 8).
It does the first bit okay, warning people about the ProductType , but if the ProductType entry is okay, but the first name is missing, I don't get a message box, it just carries on with the rest of the code.
Could someone a little more experienced than me suggest where I'm going wrong? I'm very new to VBA, so I might have done it fairly clumsily...
Code:
Private Sub FinishedButton_Click()
On Error GoTo Err_FinishedButton_Click
If Me.ProductType = "Please Select One" Then
MsgBox "You haven't selected a product type. Please select the required product and try again.", 48, "Insufficient Information"
Me.ProductType.SetFocus
ElseIf Me.FirstName = Null Then
MsgBox "You haven't entered a first name. Please do so and try again.", 48, "Insufficient Information"
Me.FirstName.SetFocus
' This bit looks at the product name and assigns a code accordingly:
ElseIf Me.ProductType = "Unit Trust" Then
ProductCode = "UT"
GoTo FinishRoutine
ElseIf Me.ProductType = "ISA" Then
Me.ProductCode = "ISA"
GoTo FinishRoutine
ElseIf Me.ProductType = "Bond" Then
Me.ProductCode = "B"
GoTo FinishRoutine
' This bit assigns a number and makes the relevant cells visible:
FinishRoutine:
Me.Finished = "Finished"
Me.AutoNumberZeroes = Format(Me.AutonumberID, "0000000")
Me.PolicyNo = Me.ProductCode & Me.AutoNumberZeroes
Me.DBInput = Now()
Me.UserName = Forms![MainMenu]![NameBox]
Me.PolicyNo.Visible = True
Me.PolicyNo_Label.Visible = True
Me.DBInput.Visible = True
Me.DBInput_Label.Visible = True
Me.UserName.Visible = True
Me.UserName_Label.Visible = True
Me.NextRecordButton.Visible = True
Exit_FinishedButton_Click:
End If
Exit Sub
Any help greatly appreciated...