Connecting Tech Pros Worldwide Forums | Help | Site Map

how can i check to see if record is already there.

Newbie
 
Join Date: Sep 2007
Posts: 7
#1: Oct 20 '09
I have a form in access that lets the user enter data. The data is information taken over the phone from a caller about someone who has committed a liter violation. Once the data has been entered the user hits the send letter button and it prints a letter in word to send a warning to the violator. I need the code to run a check to see if that violator already has a record.
When the user enters the data, i need for it to tell me that this person already has a record if one is there for them. and give a "second warning" message.

here is my code for the send letter button.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Send_Click()
  2.     'checks to see if both checkboxes are checked (Letter Sent & 2ndWarning)
  3.     If CkSentBoxesNone Then Exit Sub
  4.     'checks to see if Do Not Send checkbox is checked - If true, give msgbox warning
  5.     If CkDoNotSend = True Then Exit Sub
  6.  
  7.     PrintWarningOne
  8.  
  9. End Sub
  10.  
  11.  
  12.  
  13. ' insures both LetterSent & 2ndWarning checkboxes aren't BOTH unchecked
  14. Private Function CkSentBoxesNone() As Boolean
  15.  
  16.     If ([Forms]![frm_Input_frm]![LetterSent] = False) And ([Forms]![frm_Input_frm]![2ndWarning] = False) Then
  17.         MsgBox "You must check either ""Letter Sent"" or ""2nd Warning"" checkbox " & vbCrLf _
  18.         & "for this call/violation." & vbCrLf & vbCrLf _
  19.         & "Please choose only one checkbox.", vbOKOnly, "Choose One Checkbox"
  20.         CkSentBoxesNone = True
  21.     Else: CkSentBoxesNone = False
  22.     End If
  23.  
  24. End Function
  25.  
  26. ' checks to ensure Do Not Send box is not checked when a letter is generated
  27. ' if it is, a MsgBox warning is issued but user can override and still print
  28. Private Function CkDoNotSend() As Boolean
  29.  
  30. Dim response As Integer
  31.  
  32.     If [Forms]![frm_Input_frm]![DoNotSend] Then
  33.         response = MsgBox("The ""Do Not Send"" box is checked on this record. " & vbCrLf & vbCrLf _
  34.         & "Are you sure you want to print this letter?", 36, "Do Not Send Checked")
  35.         If response = 6 Then
  36.             CkDoNotSend = False
  37.             Else: CkDoNotSend = True
  38.         End If
  39.     Else: CkDoNotSend = False
  40.     End If
  41.  
  42. End Function

Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,181
#2: Oct 22 '09

re: how can i check to see if record is already there.


We would need some more information. If you have a table of previous violations, you can simple use a DLookup on the primary key. If it returns null, then there is no existing record.
Reply