Results 1 to 12 of 12
  1. #1
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows 7 64bit Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202

    Question Data from two tables on one form?

    This one should be pretty simple but it's giving me a headache.



    I have 2 primary forms for different states, one for Virginia and one for Washington DC. By default the Virginia form auto executes when the database is open because our company operates 90% in Virginia and we have an occasional job in DC.

    It's a ticket tracking system which is designed to alert our estimators when a ticket needs to be updated. I would like to have an alert (just a text box that says "DC Updates Due" in bold red text) on the form if any updates are due on the DC form/table.

    Virginia uses it's own table for tickets and DC uses it's own table for tickets.

    Can this be done?

    Edit: Can this line of code be modified to look in a different table: =IIf(Int([Update Date])-Int(Date())<2,"DC Updates Due")

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Are the fields in the two tables basically the same? Normally, you would not have multiple tables like that. You'd have the data in one table, with a field to indicate which state. You'd have one form, which you could filter to display either state, or both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows 7 64bit Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    That's the way I was going to have it set up but with the different states come different regulations and different systems for the tickets so the tables aren't the same, they both use a completely different set of fields. I'm sure there would have still been a way to do it like that but I needed to get her done lickity-split with my feeble Access knowledge.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    I would think you could use a DCount() to check the values in the other table. Syntax here:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows 7 64bit Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    Ok this looks like it will work... I am trying to figure out how I would use this in conjunction with the code from the first post.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    If you get stuck, post your effort and the required logic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows 7 64bit Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    I don't even know where to start honestly... I don't know the proper structure to string the two together.

    =DLookup("[Update Date]" , "[Tasks - DC]" , "Criteria=Date()<2" , "DC Updates Due")

    ???

    I want the command to check the [Update Date] field on the [Tasks - DC] table and if any dates that are less than 2 days away from the current date to display the message "DC Updates Due" in a text box on the form.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Try

    =IIf(DCount("*" , "[Tasks - DC]" , "[Update Date] < Date() + 2) > 0, "DC Updates Due","")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    I get the following message:

    The expression you entered contains invalid syntax. You may have entered an operand without an operator.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Oops, try

    =IIf(DCount("*" , "[Tasks - DC]" , "[Update Date] < Date() + 2") > 0, "DC Updates Due","")

    or

    =IIf(DCount("*" , "[Tasks - DC]" , "[Update Date] < #" & Date() + 2 & "#") > 0, "DC Updates Due","")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    Hot diggity damn it worked! Much thanks pbaldy!

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Ah good, glad we got it sorted out. I'll mark the thread solved unless you have further problems with this.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Collecting data off a form and adding to 2 tables
    By Phil Knapton in forum Access
    Replies: 1
    Last Post: 01-04-2011, 10:58 AM
  2. Cannot match same data in different tables
    By jitendrakalyan in forum Queries
    Replies: 3
    Last Post: 11-22-2010, 12:26 PM
  3. looking up data from different tables
    By deadmanmss in forum Access
    Replies: 8
    Last Post: 08-21-2010, 05:35 PM
  4. Data from three tables
    By dref in forum Forms
    Replies: 3
    Last Post: 07-21-2010, 06:17 AM
  5. Replies: 9
    Last Post: 03-24-2009, 09:19 PM

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