Comparing Records In A Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    #1

    Comparing Records In A Table

    HI there a newbie here in Visual Basic i just wanted to ask something, on how can compare records in a particular field in my table... I'am develop a time scheduling system, its like for example i have a table name called RECORDS that has a 5 fields namely, TIME START, TIME END ,DAYS,ROOM. i want to compare all records that has been save in the RECORDS to be able to test if there a conflict on it,,, first hing i wanted to is to test if there equal values of records.

    Example, the first record that has been saved has the follwing:
    TIME START: 7:00 AM, TIME END 8:00 AM, DAYS: MWF, ROOM: 101.

    then the second record that has been save is exactly equal to the first record.
    the question how i can prevent this sql statement, what is advisable to use LIKE or COMPARE...

    Can somebody tell me or site some ideas on how to solve this problem:

    And lastly

    am using this code:

    Select * from RECORDS where TIME START, TIME END, DAYS, ROOM (this is the part i dont know).. i hope someone here can help me.

    Thank you very much.... and God Bless...
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by darrel
    Select * from RECORDS where TIME START, TIME END, DAYS, ROOM (this is the part i dont know).. i hope someone here can help me.
    You said five fields - this is only four. Trying to trick us, huh? :)

    I'd say what you need to do is plug the values you have to the query, something like this...

    Select * from RECORDS where [TIME START] = www AND [TIME END] = xxx AND DAYS = yyy AND ROOM = zzz

    Note I've put square brackets around some of the the field names. A space is generally seen as a delimiter between different partsof the SQL statement, so can mess things up if it's in the middle of a field name. The brackets prevent this.

    The www, xxx, yyy & zzz, of course, represent the values that you want to check.

    If you have Microsoft Access, usually the simplest way to build queries is to let Access do it, then copy them. That is, you use the nice graphical interface to pull in the fields you want, plus in your criteria and so on. Even run the query to check that it does what you want. Then switch to the SQL view, and copy what it built for you.

    If you need to know more about SQL syntax, we can probably help, and you can get much more help in the Access forum.

    Comment

    • darrel
      New Member
      • Nov 2006
      • 72

      #3
      Thank you fo that idea Mr.Killer now i'am having ideas on how to do it, and sorry for the wrong figure...

      Mr.Killer, now what i wanted to do is like this... for example my RECORDS table has have a few records in my field which is TIME START, TIME END, ROOM and DAYS, now for example am going to save another record on it but i have to test first if the details am going to save on my table RECORDS does exist on my FIELDS... because if does exists am going to prompt the user that the data being place in my form is not valid because the details that will be save is already taken.

      for example in my RECORD table, it has a TIME START which 5:00pm, TIME END 6:00pm, ROOM, 102 & DAYS, Saturday...

      now the user will be saving exactly the same details in my RECORD table. That will an error because it will be the same, it will be a conflict on the schedule. i hope am getting my self clear... Sorry if i cant explain in exact details am having a hard time explaining in English language... hope you can help me with this. thank you...

      Comment

      Working...