Results 1 to 13 of 13
  1. #1
    aqueousdan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2016
    Posts
    20

    Can anyone see why my code is deleting parts of old records?

    I finally seem to be getting somewhere with my database. I am concentrating on my MBR section. I input date and time data and shift data into the MBR table.



    I am also taking data from other tables and filling in combo boxes with that data which then goes into the MBR table.

    I have followed examples of code to allow the combo boxes to take their information based on what is chosen in the combo box above it.

    All seems to be working great except if I fill the form in and then close it. If I fill it in and then go back to a record before, it appears to wipe out some of the data. When I then go back to the last one that I was updating, the data for the last two combo boxes (engineer and machine) are missing.

    I suspect it is to do with the code in the event procedure, such as

    Code:
    Me.Combo206.Requery
    Me.Combo206 = Empty
    etc...

    Can anyone see what i've done wrong?
    Attached Files Attached Files

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,409
    Code is hard to follow with non-descriptive control names.
    Combo126 could be cboFactoryNameLookup, etc.

    When I then go back to the last one that I was updating, the data for the last two combo boxes (engineer and machine) are missing.
    I didn't see this happening.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It might happen because the Combo Box is bound (has a control source).

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    As davegri said, you are not following a good naming convention.

    The problem is that because you are not consistent in naming objects, you have switched fields in tables.

    Tables "Engineers", "Factories" and "Machines" are using "SiteID" and "FactoryID" (number type fields),
    while table "MBR" is using "EngineerName", "SiteName", "FactoryName" and "MachineName" (text type fields).

    The row sources for the combo boxes in form "MBRForm" all have an ID field (SiteID, FactoryID, etc) as the bound field.
    What do you expect will be displayed in the "MBRForm" for the Machine control, when you store a number (6) in a text field that is supposed to have a name ("Groover")??
    (Answer is...... "Nothing")

    You need to fix table "MBR" structure.


    ----------------------------------------
    One other thing:

    EVERY module should have
    Code:
    Option Compare Database
    Option Explicit
    as the first two lines. There is a setting that will cause any NEW modules to have "Option Explicit" added. In the IDE, click on TOOLS/OPTIONS, then click on "Require Variable Declaration".

  5. #5
    aqueousdan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2016
    Posts
    20
    The combo boxes in my MBR form for the engineer and machine combo boxes were bound to MachineName and EngineerName but I couldn't get any further because I was shown an error message because the MBR table was expecting data for the MachineID and EngineerID fields. I didn't know how else to fix it.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In table "MBR":
    Why are you using fields "SiteName", "FactoryName", "EngineerName" and "MachineName" (text type fields)??

    Why aren't you using "SiteID", "FactoryID" "EngineerID" and "MachineID" (number type fields - Long Integers)???

  7. #7
    aqueousdan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2016
    Posts
    20
    I'd never even looked at Microsoft access two weeks ago... I am getting confused. I thought I needed text fields due to putting text in such as engineer names.

    Besides isn't my problem due to me trying to store numbers in text fields? I'm unsure how to change the MBR form to use the EngineerID and MachineID data to store the text from the combo boxes.

    I presume once I do that I can remove EngineerName and MachineName, etc from the MBR table?

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    aqueousdan,

    Do you have a clear description of what you are trying to do? That is the business and related processes to be supported with your database. Can you share that with us?
    I 'm seeing issues/problems in design and/or Access, but nothing to compare what you have with what you are trying to build.

  9. #9
    aqueousdan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2016
    Posts
    20
    I work as an engineer for a company that makes a product over several sites. Each site has factories which have machines and engineers who maintain those machines.

    At the moment, each time a breakdown occurs on a machine and an engineer fixes the problem we record it (the MBR) on a piece of paper and file it away. I am trying to create this with access.

    I want to be able to add engineers and machines using forms as well as the MBR form itself. I want the combo boxes to cascade to make things easier for the people inputting data into this database.

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by aqueousdan View Post
    I'd never even looked at Microsoft access two weeks ago...
    Hmmmm.... Looks like you have been thrown in the deep end without your water wings.
    You should really work through some tutorials to learn the basics.

    Maybe it will help you if you compare your dB to mine....... I used descriptive object names and changed the table "MBR".
    If you DON'T understand what I changed, you will have probably have problems later on.
    Attached Files Attached Files

  11. #11
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    Dan,

    I agree with Steve. Here are 3 videos to watch to help with concepts:
    Intro to Database
    The Relational Model
    Data modeling

    Spend 30-45 minutes working through one of these tutorials from RogersAccessLibrary. They show the Problem, the Process and include solutions. You can use this technique with any database.

    Class Info
    and/or
    Consolidated Widgets

    Good luck.

  12. #12
    aqueousdan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2016
    Posts
    20
    I notice you have taken out the EngineerName, FactoryName, etc and there is now just the ID fields. I think you have then made a query which is pulling from the MBR table and youve then based the MBR Form on that. I cant however see why because there just seems to be the same data in the query as is in the table.

    It looks like I was on the right track with the combo boxes for the MBR sheet to pull the information from the respective tables but the names of the combo boxes mean something now. I had done that originally, although not quite as well, but ended up deleting and putting more in a few times in frustration

    I notice a menu which is fantastic and has code for it in the scary visual basic part of the program.

    Could you please explain to me the add/edit Factories form? I see you have a combo box which shows the Site name and also the Factory name. Why is there a box for the Factory ID there that is invisible? and how are the combo boxes repeating down the form?

    Thankyou so much for your help with this, although I was heading in a sort of good direction, I dont think I would have got to the correct solution by myself.

    I have started to watch the information videos right now.

  13. #13
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by aqueousdan View Post
    Could you please explain to me the add/edit Factories form? I see you have a combo box which shows the Site name and also the Factory name. Why is there a box for the Factory ID there that is invisible?
    That is my "style" (such as it is ) In the past, I had trouble adding records in some forms, so I add and hide the PK field.
    I use autonumber fields as PK fields and autonumber fields have no real world meaning.
    Since autonumber fields have no real world meaning, autonumber PK fields should never be displayed, thus it is hidden.



    Quote Originally Posted by aqueousdan View Post
    and how are the combo boxes repeating down the form?
    This is easy.. The form is set to Continuous Forms view. You could set the default view to Single Form, but then you would have to keep hitting the next button to see other records.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-30-2014, 11:04 AM
  2. Replies: 2
    Last Post: 01-04-2013, 12:41 PM
  3. Replies: 3
    Last Post: 08-02-2012, 11:37 AM
  4. deleting records
    By radicalrik in forum Queries
    Replies: 2
    Last Post: 07-14-2010, 03:10 PM
  5. Replies: 0
    Last Post: 11-28-2005, 01:04 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