Hi ,
Could someone please help me with the VBA code behind my post button which is on my mainform. What I want is to check that the following controls have been populated. The first three work fine (Title, TransactionDate and Username) but as soon as I try the subform it doesn't work properly. If I deliberately leave out say CC and then click the post button it say's "please enter a/c no" and then comes up with "There is an invalid method in an expression".
I'm probably doing something really daft.
cheers
Wrightie
This is the code I'm using ...
Could someone please help me with the VBA code behind my post button which is on my mainform. What I want is to check that the following controls have been populated. The first three work fine (Title, TransactionDate and Username) but as soon as I try the subform it doesn't work properly. If I deliberately leave out say CC and then click the post button it say's "please enter a/c no" and then comes up with "There is an invalid method in an expression".
I'm probably doing something really daft.
cheers
Wrightie
This is the code I'm using ...
Code:
Private Sub Post_Click()
On Error GoTo Err_Post_Click
If Len(Nz(Title, "")) = 0 Then
MsgBox "You must enter a Title", , "Input Error!"
Cancel = True
Title.SetFocus
Exit Sub
End If
If Len(Nz(TransactionDate, "")) = 0 Then
MsgBox "You must enter a Transaction Date", , "Input Error!"
Cancel = True
TransactionDate.SetFocus
Exit Sub
End If
If Len(Nz(UserName, "")) = 0 Then
MsgBox "You must select a Username", , "Input Error!"
Cancel = True
UserName.SetFocus
Exit Sub
End If
If Len(Nz(Me.Journal_Entries_Subform.Form.AcNo, "")) = 0 Then
MsgBox "Please enter an A/c No", , "Input Error!"
Cancel = True
Me.Journal_Entries_Subform.Form.SetFocus
Exit Sub
End If
If Len(Nz(Me.Journal_Entries_Subform.Form.CC, "")) = 0 Then
MsgBox "Please select a CC", , "Input Error!"
Cancel = True
Me.Journal_Entries_Subform.Form.SetFocus
Exit Sub
End If
If Len(Nz(Me.Journal_Entries_Subform.Form.Dept, "")) = 0 Then
MsgBox "Please enter a Department", , "Input Error!"
Cancel = True
Me.Journal_Entries_Subform.Form.SetFocus
Exit Sub
End If
End Sub