Results 1 to 6 of 6
  1. #1
    osfar is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    6

    Question how to check if the same record is exist before insert it ?

    hello .


    I'm working in small access program about members of faculty , and keep track of their scientific mission to another countries

    i got 2 tables : 1 for member personnel detail (MemberID,MemberName,College,Department,Degree,Gen eral_specifation,
    Specialization,Date_Of_Hiring,MasterDate,PHD_Date)

    and the other table for mission for each member

    (MemberID,MissionType,Date_of_approve,Destination,TravelDate,ReturnDate,
    DepartmenapproveDate,FacultyApproveDate,UnivApproveDate,ExtendDate1,ExtendDate2,ExtendDate3)


    this is the first form to enter the Member Detail.


    -----------------------


    and this is the second form to enter the Mission Details (unbounded)
    first i pick the member name from the first combobox (which is inserted in the first Form)
    thin i fill all mission details
    and insert the data using SQL
    Code:
    Private Sub Command31_Click()
    Dim strSQL As String
    strSQL = "insert INTO DData([member_ID],[Mission_ID],[order],[Destination],[travelDate],[returnDate],[extend1],[extend2],[extend3],[depCon],[FacCon],[collCon]) Values ('" & Me.Combo0.Column(0) & "','" & Me.Combo3.Column(0) & "','" & Me.m1 & "','" & Me.m3 & "','" & Me.m4 & "','" & Me.m5 & "','" & Me.m6 & "','" & Me.m7 & "','" & Me.m8 & "','" & Me.m9 & "','" & Me.m10 & "','" & Me.m11 & "');"
    CurrentDb.Execute strSQL
    End Sub


    now i got some questions
    1- how to check if i inserted this mission before for the same Member ?
    2- i have 4 types of missions , each type can be extended for specific times and specfic period
    Type1 , Type2 ,Type 3 , Type 4
    for example Type 1 period is 4 years and can't be extended
    Type 2 can be extended to 2 years Maximum and each extend is 3 months only
    how to handle that in my tables
    3- how to make a report from two tables if i want to show missions for each member ?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    how to check if i inserted this mission before for the same Member ?
    What field or combination of fields makes a record unique in your table DData?
    Make a unique composite index of those fields and Access will not allow duplicates.
    You can trap the error when such an attempt occurs and provide a message to the user.
    Another option is to use a Dcount(your criteria) >0 -which means a record with (your criteria) already exists - so take some other action, such as a message...

  3. #3
    osfar is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    6
    i can use the order and travel date as unique keys , now how prevent duplicate ?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  5. #5
    osfar is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    6
    I've done the tutorial exactly , but it only prevent duplicates in one field , even if the other fields i specified got different data
    how to fix that

  6. #6
    osfar is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    6
    thanks man it worked , but when i try to insert the same row i don't get any error messages but the row isn't inserted

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-02-2016, 02:57 AM
  2. Replies: 15
    Last Post: 09-14-2015, 01:31 PM
  3. Check if record exist and update the status
    By JustinC in forum Access
    Replies: 4
    Last Post: 08-17-2014, 01:39 PM
  4. Check if record exist
    By sahand in forum Forms
    Replies: 2
    Last Post: 06-11-2014, 07:07 AM
  5. Check if record exist
    By khhess in forum Programming
    Replies: 1
    Last Post: 06-14-2011, 06:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums