Hello,
I am in the process of developing a form for use in sales office to capture opportunity information and have run across a bit of a problem.
I am looking to use the 'tag' data validation method because I wish to have a different input form for the administrator and the sales lead. Sometimes the sales lead will request the administrator to fill in information and not give them the full story, so they still need to get the data in without disrupting the admin's workflow. (We are still working on fixing that process.)
The original post where I captured this method found here: access-programmers[DOT]co.uk/forums/showthread.php?t=207813 - Thank you very much CraigDolphin!! (I had to remove the link due to post count), which uses the following code as a general module:
Then, we call the function using he following code on command click:
Now, to describe the problem statement.
First, I'm having difficulty getting this code to work correctly on command click and I'm receiving the following Compile Error: Method or Data member not found.
Secondly, I need to modify the code to allow additional code to run as I will also be generating notification emails and creating and saving excel documents upon command click (those codes are already created and working) and (prior to testing this..) I fear that the If Then Else function appears to be closing the form prematurely.
I've only made a few applications with VBA and may just need some discussion to work this problem out. Any help or thoughts would be greatly appreciated.
I am in the process of developing a form for use in sales office to capture opportunity information and have run across a bit of a problem.
I am looking to use the 'tag' data validation method because I wish to have a different input form for the administrator and the sales lead. Sometimes the sales lead will request the administrator to fill in information and not give them the full story, so they still need to get the data in without disrupting the admin's workflow. (We are still working on fixing that process.)
The original post where I captured this method found here: access-programmers[DOT]co.uk/forums/showthread.php?t=207813 - Thank you very much CraigDolphin!! (I had to remove the link due to post count), which uses the following code as a general module:
Code:
Public Function validateform(myform As Form) As Boolean
'returns true if all required fields have data, or false if not.
'It will also create a popup message explaining which fields need data
Dim boolresponse As Boolean
Dim strError As Variant
Dim ctl As Control
boolresponse = True
strError = Null
With myform
For Each ctl In .Controls
With ctl
If .Tag = "Required" Then
If .Value & "" = "" Then
boolresponse = False
strError = (strError + ", ") & .Name
End If
End If
End With
Next ctl
End With
If strError & "" <> "" Then MsgBox "The following information must be entered first: " & strError, vbInformation
validateform = boolresponse
End Function
Code:
Private Sub Save_Form_Click()
On Error GoTo Err_Save_Form_Click
If Me.PrimaryID & "" <> "" Then
If validateform(Me) Then DoCmd.Close
Else
DoCmd.Close
End If
Exit_Save_Form_Click:
Exit Sub
Err_Save_Form_Click:
MsgBox Err.Description
Resume Exit_Save_Form_Click
End Sub
First, I'm having difficulty getting this code to work correctly on command click and I'm receiving the following Compile Error: Method or Data member not found.
Secondly, I need to modify the code to allow additional code to run as I will also be generating notification emails and creating and saving excel documents upon command click (those codes are already created and working) and (prior to testing this..) I fear that the If Then Else function appears to be closing the form prematurely.
I've only made a few applications with VBA and may just need some discussion to work this problem out. Any help or thoughts would be greatly appreciated.