Private Sub txtAddDonor_AfterUpdate()
Dim DonorNum As String
Dim DonorName As String
Dim ValidDonorID As Integer
Dim StrFix As String
Dim LResponse As Integer
DonorNum = Nz(Me.txtAddDonor.Value) 'Name of textbox
'This code pads id with leading zero if not present.
If Len(DonorNum) > 1 Then
StrFix = Nz(Me.txtAddDonor.Value)
DonorNum = String(10 - Len(DonorNum), "0") & StrFix
Else
End If
Me.txtAddDonor.Value = DonorNum
DonorName = Nz(DLookup("Pref_Mail_Name", "dbo_LMC_Entity", "id_Number= '" & DonorNum & "'"))
If Len(DonorName) > 2 Then
ValidDonorID = 1
Else
ValidDonorID = 0
End If
If ValidDonorID = 1 Then
LResponse = MsgBox("Is this the Donor your looking for " + DonorName + "?", vbYesNo, "Continue")
If LResponse = vbYes Then
MsgBox ("Adding new prospect!") '**** THIS IS WHERE THE CODE WILL GO TO UPDATE THE TABLE **** - Stored Procedure
'*****Run sproc to add new donor to CPM *************************
'Dim db As DAO.Database
Dim qdf As DAO.QueryDef
'Dim rst As DAO.Recordset
'Set db = CurrentDb
'Set qdf = db.CreateQueryDef("")
'qdf.Connect = db.TableDefs("dbo_CPM_Donors").Connect
'MsgBox DonorName
qdf.SQL = "EXEC dbo.usp_NewCPM_Item ='" & DonorNum '" 'Simple adds a row
'qdf.ReturnsRecords = False
'qdf.Execute dbFailOnError
'Set qdf = Nothing
'Set cdb = Nothing
'******End of sproc ********************************************
MsgBox ("New prospect added!")
Else
MsgBox ("Please try again!")
End If
Else
MsgBox ("Donor with Id_Number: " & DonorNum & " does not exist, try again or add to Advance!")
Me.txtAddDonor.Value = ""
End If
End Sub