Results 1 to 13 of 13
  1. #1
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    Lookup Previous Record for a value

    I have a data base I am working on and it I have one box that I want to have look up the value in the same box in the previous record once I click on the Comand Button. I have never had to do this other than the Find Previous Comand Button in the past.

    Lloyd

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    did not help

    Thank you for the link but did not really help me much as I need the function I am looking for to happen in the database because I have several Querries

    Lloyd



    Quote Originally Posted by orange View Post

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Can you post a copy of your mdb -- remove confidential/personal info?
    Can you provide a jpg of your form set up and a description of what exactly you want to happen?

  5. #5
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    Document with JPG and description

    I have attached a word document with a JPG in the document show the User Interface page. In this database I have 3 boxes associated with”PROCEDURE NUMBER” they perform the following functions;

    1. The first box is automatically updated when the procedure Identifier is entered into the “PROCEDURE IDENTIFIER” text box.
    2. The second box is automatically updated when the Project Number is entered into the “PROJECT NUMBER” text box.
    3. The third box needs to perform an automatic function. After the above two steps have been completed the user will then click on the “PROCEDURE NUMBER” tab and the code for this box will perform the following steps :
      1. Look up the last record for the “PROCEDURE IDENTIFIER”.
      2. Once last record for that “PROCEDURE IDENTIFIER” is found then the following function is performed;

    If Me.PROCEDURE_NUMBER > 300 Then Me.PROCEDURE_NUMBER = 300
    If Me.PROCEDURE_NUMBER < 299 Then Me.PROCEDURE_NUMBER = Me.PROCEDURE_NUMBER + 1
    In this database I have 3 boxes associated with”PROCEDURE NUMBER” they perform the following functions;
    Attached Thumbnails Attached Thumbnails User Interface.png  

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Fuzzy screen shots make my eyes bleed! Orange was asking for you to make a copy of your database, remove any confidential material from the copy, then compact/repair, zip it up and upload it to the site. Screen shots really are not helpful for determining your data structure, what your form is doing, etc.

  7. #7
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    Previous file

    Sorry about that here it is. As you can see for the most part it is a very simple database other than I havenever had a field look backwards as part of it process.

    Lloyd

    ENGINEERING PROCEDURES.zip

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I do not understand your database. There is no sample data. There is only 1 table, but you seem to be dealing with some sort of hierarchy -- Project and Procedure and Client. It appears, and this is just a guess, that you need to normalize your table into related tables based on your Business rules.

    Can you tell us (describe to us) exactly WHAT your table represents?

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I agree with orange this is a poorly constructed database.

    Really what you want is an individual table for each of the following (at the very least)
    tblProcedures (fields would be something like Proc_ID (autonumber PK), Proc_Code, Proc_Description)
    tblProjects (fields would be something like Proj_ID (autonumber PK), Proj_StartDate, Proj_EndDate, Proj_Supervisor, if you're tracking who's responsible for a project the Proj_supervisor would be a foreign key to an employee table)
    tblProj_Procedures (this would be a table that records all of the procedures performed for a specific project so you'd have something like Proj_Proc_ID (autonumber PK), Proj_ID, Proc_ID, <any other fields necessary to record individual processes on a single project)
    tblClients (Client_ID (autonumber pk), ClientName, Client_ContactFN, Client_ContactLN, <other client related fields>)


    The design you currently have is basically just a spreadsheet which is going to make your data incredibly hard to work with over time.

    For instance let's say someone Types in a client name of 'Bob Smith', another person types it in as 'Robert Smith' and another types in it as 'bobby smith'

    Whenever you query your results even though this may be the exact same client you will never be able to correlate them to one another through code over your entire data set.

    What you're doing with your existing code is looking at ONE field, if that field is below a certain number you're changing it to a different number (basically invalidating whatever someone wrote in so why allow it as data entry to start with)

    There's nothing in this database to use an as example (again as orange pointed out) either

    Code:
        Find Previous Me.PROCEDURE_IDENTIFIER
        If Me.PROCEDURE_NUMBER > 300 Then Me.PROCEDURE_NUMBER = 299
        If Me.PROCEDURE_NUMBER < 299 Then Me.PROCEDURE_NUMBER = Me.PROCEDURE_NUMBER + 1
    this is the code attached to the button I think you're talking about it looks like you're trying to find the last record that had this particular procedure_identifier, but what are you doing with that, are you saying if the previous procedure numbers was less than 300 you want the 'new' procedure number to be 299? And if the previous procedure numbers was less than 299 you want the 'new' procedure number to be incremented by 1? what happens in this scenario if your prevoius procedure identifier is 299 or 300 exactly, they would be completely ignored by your pesudo code.

    Please think about normalizing your tables rather than trying to continue with this design.

  10. #10
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    Currently this is what we want it to do;

    1st Entry= Needless to say the first box is the Date the new Procedure Number is Created

    2nd Entry= Procedure Identifier. The person enters this information based on the Identifier listed at the very bottom of the page as show, i.e. AP, AR etc.

    3rd Entry= Project Number is a mu,ner that has been assigned by our accounting department for a given project, i.e. 4000, 2827 etc.

    4th Entry= Procedure Number, The first box is updated whenever the Procedure Identifier is entered into the Procedure Identifier Box. Second box is updated once the Project Number is entered into the Project Number box. Third box is where we want it to look back at the last Procedure Identifier entry for what has been entered and then add 1 for the next number, if there is no entry for this Identifier then it will start out at 300. (I understand that the first and second box is redundant data but they wanted all this side by side so that once the data was entered it would look like this "AL-4000-299" which would be the Procedure Number for the document)

    5th entry= Client since we have Clients with multipul addemums to their name depending on which office they work out off this coule vary a lot we are not worried about that.

    6th Entry= Created By is by whom ever enters the data for the document number and does not have anything to do with project managment.

    This database has nothing to do with tracking supervisor, project managers etc as it is meant to help prevent duplicate Procedure Numbers from being created.

    I have created Inventory Databases before but have never had to build a database like this where a numbering valve was taken from a previous entry.




    Quote Originally Posted by rpeare View Post
    I agree with orange this is a poorly constructed database.

    Really what you want is an individual table for each of the following (at the very least)
    tblProcedures (fields would be something like Proc_ID (autonumber PK), Proc_Code, Proc_Description)
    tblProjects (fields would be something like Proj_ID (autonumber PK), Proj_StartDate, Proj_EndDate, Proj_Supervisor, if you're tracking who's responsible for a project the Proj_supervisor would be a foreign key to an employee table)
    tblProj_Procedures (this would be a table that records all of the procedures performed for a specific project so you'd have something like Proj_Proc_ID (autonumber PK), Proj_ID, Proc_ID, <any other fields necessary to record individual processes on a single project)
    tblClients (Client_ID (autonumber pk), ClientName, Client_ContactFN, Client_ContactLN, <other client related fields>)


    The design you currently have is basically just a spreadsheet which is going to make your data incredibly hard to work with over time.

    For instance let's say someone Types in a client name of 'Bob Smith', another person types it in as 'Robert Smith' and another types in it as 'bobby smith'

    Whenever you query your results even though this may be the exact same client you will never be able to correlate them to one another through code over your entire data set.

    What you're doing with your existing code is looking at ONE field, if that field is below a certain number you're changing it to a different number (basically invalidating whatever someone wrote in so why allow it as data entry to start with)

    There's nothing in this database to use an as example (again as orange pointed out) either

    Code:
        Find Previous Me.PROCEDURE_IDENTIFIER
        If Me.PROCEDURE_NUMBER > 300 Then Me.PROCEDURE_NUMBER = 299
        If Me.PROCEDURE_NUMBER < 299 Then Me.PROCEDURE_NUMBER = Me.PROCEDURE_NUMBER + 1
    this is the code attached to the button I think you're talking about it looks like you're trying to find the last record that had this particular procedure_identifier, but what are you doing with that, are you saying if the previous procedure numbers was less than 300 you want the 'new' procedure number to be 299? And if the previous procedure numbers was less than 299 you want the 'new' procedure number to be incremented by 1? what happens in this scenario if your prevoius procedure identifier is 299 or 300 exactly, they would be completely ignored by your pesudo code.

    Please think about normalizing your tables rather than trying to continue with this design.

  11. #11
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    One thing that was decided at work today was we would not perform searches on who created the new Procedure Number.

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'm not sure where you are on this project but with your description I think it's even more important that you put some effort into normalizing your data. You are thinking of your data as a spreadsheet where you will be carrying a lot of data that is duplicate information in the same table. What you should be doing is looking for ways to economize the space/data you use. The easiest to explain, but not the only one, for your database is to have a client table with an autonumber primary key.

    When you have a client table with all the client specific information in it and you have a primary key (autonumber is just the easiest to work with) all you have to store in your 'main' table is the customer number, which can be obtained by putting a combo box on your main form with the primary key as the bound column. Instead of repeating that customer information time after time after time you have *1* place where you maintain any contacts, phone numbers, company name, etc. If you construct things this way you when you go to query your results you can produce a homogeneous set of data rather than risk the fickle fingers of fate that take people when they type things in rather than choose from a list.

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I agree that normalization and getting a data model designed to match your needs is a key first step.
    See the first few topics here Normalization, Entity Relationship Diagramming and the 12 steps.
    http://www.rogersaccesslibrary.com/forum/topic238.html

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

Similar Threads

  1. Replies: 8
    Last Post: 07-06-2013, 05:13 PM
  2. Replies: 22
    Last Post: 06-12-2012, 10:02 PM
  3. Replies: 3
    Last Post: 11-23-2011, 12:25 AM
  4. Previous record
    By leonhuynh2006 in forum Forms
    Replies: 1
    Last Post: 10-06-2011, 06:41 AM
  5. Replies: 1
    Last Post: 07-25-2011, 09:41 AM

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