Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > [Access] Compare fields in 2 tables to find


Reply
 
Thread Tools Display Modes
  #1  
Old 03-23-2010, 01:27 PM
InFy's Avatar
InFy InFy is offline
Freshman
 
Join Date: Mar 2004
Posts: 30
Default [Access] Compare fields in 2 tables to find


Edit: title doesn't make sense because I didn't finish it before posting.
Compare fields in 2 tables to see if values are equal

Following situation:

I have 2 tables:
1 containing names and a date when they had signed the current procedures on site
1 with people who are 'in' or 'out'

Currently, when a person visits the site twice, there will be 2 records of him visiting. On the other hand, there's only 1 record of each person in the procedures table with the date field, which gets updated accordingly.

Right now there's someone entering names in the visitor table, this needs to look for the same name in the procedure table, if a name is found it should look at the date when the procedure was signed. If it's more than 6 months ago, the visitor needs to read and sign them again.

I'm stuck with the comparison of the table fields.
I can figure out the date check and popup myself if not included in code samples.

Thanks in advance!
Reply With Quote
  #2  
Old 03-30-2010, 12:15 PM
InFy's Avatar
InFy InFy is offline
Freshman
 
Join Date: Mar 2004
Posts: 30
Default

I have created a selection query that will only show the date matched to the names.

Then in the code I use (shortened)

Code:
Dim dtDate As Date
Dim qry As String

qry = "Name of the selection query" 'This has to be the name you gave it, including the spaces, query between ""

    If Not IsNull(DLookup("Datum", qry)) Then
        dtDate = DLookup("Datum", qry)
    End If
Then you can output the dtDate via various ways (msgbox, textbox, ...) or use it to compare.

I used it to check if the dtDate is older than 6 months or not, then show a popup.


Code:
    If dtDate <> 0 Then
        intDateDiff = DateDiff("d", dtDate, Date)

        If (intDateDiff > 183) Then
            popup = MsgBox("The date is older than 183 days.")
        End If
    End If

I'll be checking this thread for the next week, so if any question, now's the time
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->