I am not sure if this is a Query or Form Question...Maybe both...
Here’s my problem…
I have a SubForm based on a query. The query is designed so that only the current users records are shown. On the SubForm I have an AfterUpdate Event on the PhoneNumber field, to help Prevent one Salesperson from entering another Salespersons Contact. It all works great with one exception. Even though all of the records are stored in the “tblcontacts” table. The AfterUpdate Event below is only looking back at the current users records. Any idea as to how I can make it look at all the records?
Private Sub PhoneNumbers_AfterUpdate()
Dim Answer As Variant
If DCount("[LastName]", "tblcontacts", "[LastName]=[Forms]![Master]![frm-QryBySalesperson].[Form]![LastName]") _
And DCount("[FirstName]", "tblcontacts", "[FirstName]=[Forms]![Master]![frm-QryBySalesperson].[Form]![FirstName]") _
And DCount("[MI]", "tblcontacts", "[MI]=[Forms]![Master]![frm-QryBySalesperson].[Form]![MI]") _
And DCount("[DOB]", "tblcontacts", "[DOB]=[Forms]![Master]![frm-QryBySalesperson].[Form]![DOB]") _
And DCount("[PhoneNumbers]", "tblcontacts", "[PhoneNumbers]=[Forms]![Master]![frm-QryBySalesperson].[Form]![PhoneNumbers]") Then
Answer = MsgBox("This Customer is already in the Database", vbOKOnly, "Hey You!")
If Answer = vbOK Then Cancel = True
DoCmd.SetWarnings Off
DoCmd.GoToRecord , , acNewRec
Me.Title.SetFocus
Exit Sub
End If
End Sub
Many Thanks,
Don
[This message has been edited by donbettis (edited 11-15-2001).]
Here’s my problem…
I have a SubForm based on a query. The query is designed so that only the current users records are shown. On the SubForm I have an AfterUpdate Event on the PhoneNumber field, to help Prevent one Salesperson from entering another Salespersons Contact. It all works great with one exception. Even though all of the records are stored in the “tblcontacts” table. The AfterUpdate Event below is only looking back at the current users records. Any idea as to how I can make it look at all the records?
Private Sub PhoneNumbers_AfterUpdate()
Dim Answer As Variant
If DCount("[LastName]", "tblcontacts", "[LastName]=[Forms]![Master]![frm-QryBySalesperson].[Form]![LastName]") _
And DCount("[FirstName]", "tblcontacts", "[FirstName]=[Forms]![Master]![frm-QryBySalesperson].[Form]![FirstName]") _
And DCount("[MI]", "tblcontacts", "[MI]=[Forms]![Master]![frm-QryBySalesperson].[Form]![MI]") _
And DCount("[DOB]", "tblcontacts", "[DOB]=[Forms]![Master]![frm-QryBySalesperson].[Form]![DOB]") _
And DCount("[PhoneNumbers]", "tblcontacts", "[PhoneNumbers]=[Forms]![Master]![frm-QryBySalesperson].[Form]![PhoneNumbers]") Then
Answer = MsgBox("This Customer is already in the Database", vbOKOnly, "Hey You!")
If Answer = vbOK Then Cancel = True
DoCmd.SetWarnings Off
DoCmd.GoToRecord , , acNewRec
Me.Title.SetFocus
Exit Sub
End If
End Sub
Many Thanks,
Don
[This message has been edited by donbettis (edited 11-15-2001).]