Results 1 to 6 of 6
  1. #1
    abidib is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    4

    Assigning numbers from one table to its definitions on different table?


    I am the only person in the company with some computer experience and I was asked to create a GUI in the database. In Microsoft access I have 2 tables. In the first table I have a list of a 1000 numbers ranging from 01-09 like 01, 03, 06, 03, 09, 02....And in the second table I have the definitions of what those numbers mean like 01 means "empty" 02 means "call back" 03 mean "not available" and so on. In the GUI how do I get the definitions of those numbers to show in the textfeild because right now only the numbers show. Thanks for any kind of help by the way, I really appreciate it!

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Why do you have this data in two Tables instead of in a single Table? This seems counter-productive.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    abidib is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    4
    Hi thanks for replying. There is a 1000 different Customer ID's which my co-workers provide me in table 1. Table 1 has customer name, address, status, postal code.... In the GUI they asked me to create, they wanted the definitions of those "Status" numbers to show, which is why I created the second table. In the second table I just have numbers 01-09 and the corresponding definition of what those "Status" numbers mean, and in the GUI they want the definitions to show NOT the numbers.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    That makes more sense! As usual, there are several ways to do this. Because 'descriptions' tend to be long, I'll describe a method to return the description Field even if it is defined as a Memo Field (or Long Text Field, in the latest versions of Access.)

    Where

    • txtStatus is the Form Textbox where the user enters the status designation (i.e. 01, 02, 03, etc)
    • txtStatusDescription is the Form Textbox that holds the status description
    • Status is the Table Field that holds the status designation
    • StatusDescription is the Table Field that holds the status description
    • StatusTableName is the actual name of the Table that holds the status and status description

    Code:
    Private Sub txtStatus_AfterUpdate()
     Me.txtStatusDescription = Nz(DLookup("StatusDescription", "ActualTableName", "Status ='" & Me.txtStatus & "'"), "Status Does Not Exist!")
    End Sub

    When the user enters the Status and moves off of the Textbox, the Description Textbox will be populated with the appropriate Description. If the Status does not exist in the Table, the Description Textbox will display the message

    Status Does Not Exist!

    You might want to use Conditional Formatting to change the Fore Color or Back Color to another color, if the Description Textbox equals to 'Status Does Not Exist!,' as a warning to your users.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    abidib is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    4
    WOW you make it seem so simple. Thank you so much! appreciate it!
    Quote Originally Posted by Missinglinq View Post
    That makes more sense! As usual, there are several ways to do this. Because 'descriptions' tend to be long, I'll describe a method to return the description Field even if it is defined as a Memo Field (or Long Text Field, in the latest versions of Access.)

    Where

    • txtStatus is the Form Textbox where the user enters the status designation (i.e. 01, 02, 03, etc)
    • txtStatusDescription is the Form Textbox that holds the status description
    • Status is the Table Field that holds the status designation
    • StatusDescription is the Table Field that holds the status description
    • StatusTableName is the actual name of the Table that holds the status and status description

    Code:
    Private Sub txtStatus_AfterUpdate()
     Me.txtStatusDescription = Nz(DLookup("StatusDescription", "ActualTableName", "Status ='" & Me.txtStatus & "'"), "Status Does Not Exist!")
    End Sub

    When the user enters the Status and moves off of the Textbox, the Description Textbox will be populated with the appropriate Description. If the Status does not exist in the Table, the Description Textbox will display the message

    Status Does Not Exist!

    You might want to use Conditional Formatting to change the Fore Color or Back Color to another color, if the Description Textbox equals to 'Status Does Not Exist!,' as a warning to your users.

    Linq ;0)>

  6. #6
    abidib is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    4
    Hey thanks a lot by the way but I am sorry to bother you again, but do you put the code into the "Control Source" of the txtStatusDescription. I have no idea where to properly enter the code. Thanks

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

Similar Threads

  1. Assigning multiple sequential numbers to orders
    By jree3000 in forum Programming
    Replies: 14
    Last Post: 09-09-2014, 04:35 PM
  2. Exporting Table Definitions
    By EddieN1 in forum SQL Server
    Replies: 5
    Last Post: 09-01-2012, 09:57 AM
  3. Assigning a Lot number to table of information
    By mmirandola in forum Database Design
    Replies: 4
    Last Post: 05-24-2012, 08:21 PM
  4. Assigning numbers to certain fields
    By smartflashes in forum Programming
    Replies: 6
    Last Post: 01-19-2012, 05:14 PM
  5. Replies: 3
    Last Post: 01-21-2010, 08:10 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