Results 1 to 12 of 12
  1. #1
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218

    Main Form Sub Form Issues

    I've been working on a database which stores customer information, building/room information, and equipment information. Its coming along nicely. I've created a customers form which displays the buildings and rooms that they're associated to. It is 95% complete and works how I want it to.

    I'm trying to create a rooms form, titled frmMainRooms. I want to be able to search for a building name and room number. Then I want to see:

    1. Who owns the room (may be more than one, datasheet view would work). Will need all information about this customer.
    2. How room is secured.
    3. Cabinet Name and key name for cabinet (can be more than one cabinet).
    4. Equipment which is in the room.
    5. Equipment which is in the cabinet.

    My biggest problem is creating a customers subform. I would need to link the customer ID from my main form to the customer ID from my subform (the PK in my customers table). The problem is my main form is based on a query of building ID/name and room ID/name. I do not have customer ID in my main form. I could add it to the query but that would limit the results of my building/room query to only those who are associated with a customer. In my main form, I want to see all buildings/rooms whether they have 0 customers, or 20.

    My other problem is I do not know how to make equipment in room/ equipment in cabinet less complicated and more user friendly. I really would like if equipment was only one subform. If I had two, not all rooms have cabinets (and therefore, wouldn't have any equipment in that cabinet). Plus thats two places to look for information, could get confusing.



    I appreciate your help. BuildingsSwitches3 (3).zip

  2. #2
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Why would adding a customer ID in your main form limit the results of a query ?
    You just add the field to the query and as long as you don't set any conditions for that field it will just be in the results.

    Or am i missing your point ?

  3. #3
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    I think so.

    As it is now, it queries building table and rooms table. I need to see all the buildings and rooms. If I add the customers to rooms table it will also query what's in that table. That's my junction table which contains customer id and room id. So if I add that table and add the customer ID field, it will show only the records which are in the junction table. So, if I've added a room recently and have not yet added a customer to the room, it will not show up.

  4. #4
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    I've attached an image which illustrates my problem. If I create the query without customer ID, customer ID is not in the record source for my main form. As such, I cannot link a customers subform to my main form. If I add my CustomersToRooms table and include CustomerID from that table, then the query works and I can link the subform to my main form. However, it will display only the rooms that are associated to a customer. Basically, only if there is data in my customers to rooms table. So, if I add a new room but that room has no customers, it will not show up on my query.

    How can I fix this? Is VBA required? Click image for larger version. 

Name:	room query.jpg 
Views:	26 
Size:	84.2 KB 
ID:	22022

  5. #5
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    Alternatively, I could scrap the idea of creating a Rooms main form and just continue to perfect my customers main form. I'm having issues keeping all that information (customer info, room info, equipment info) on one form. If I have customer info as my main form, then I create a subform for rooms, that subform will display room information (whats in my rooms table). If I select one customer, it shows me the many rooms which that customer owns. Now, if rooms is in datasheet view and there are many rooms, I cannot also display cabinet info and then switch info. A possible solution to this is to create a hyperlink in my data cell that will open up a popup form that displays the cabinets in room (if any) and then the equipment in the cabinets. But I'm not sure if the popup form can then be searched or not.

    It seems more user friendly to create a form that searches by room name and displays the customers, cabinets, and switches... All in separate subforms.

  6. #6
    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,870
    I think you may be trying to do everything in 1 step.
    What exactly is this form/query for?
    In post 1
    I'm trying to create a rooms form, titled frmMainRooms. I want to be able to search for a building name and room number. Then I want to see:

    1. Who owns the room (may be more than one, datasheet view would work). Will need all information about this customer.
    2. How room is secured.
    3. Cabinet Name and key name for cabinet (can be more than one cabinet).
    4. Equipment which is in the room.
    5. Equipment which is in the cabinet.
    Going back to post 3
    it queries building table and rooms table. I need to see all the buildings and rooms.
    When you are looking at an application - specifically information about some entity(s) -you have to consider:
    -how to populate the XXX
    -what range of values is appropriate
    -is it dependent on something else
    -if so, does that thing already have a value
    -another concern is, is this the right time/place to capture that info

    Obviously, you can't get data out, if it never went/got input.
    If you have things that are independent until brought together ie: Customer and Room(I'm ignoring bldg for this)
    you could have a "populating form" including a list of Customers, and a list of Rooms (independent combos for example), and a Button.
    You make a selection in cboCustomer, and a selection in cboRoom --then click the button to create a record indicating that this Customer is assigned to this Room (in your CustomerToRoom table).
    You would also have a compound unique index on that table to prevent duplicate assignments.
    On the code behind the button click, you would also be validating that there was no existing record for that combination. If there was an attempt to add a duplicate, intercept the Access error with something more friendly.

    In overview, the method to populate the tables, may not be the same as the method you use to retrieve or display related records. When you populate a table, there are no existing records, and when you add a record (or subsequent records), you have to avoid duplicates.

    It is important to get the logic of what you want to happen clearly defined and tested. You could populate several things from one form, but don't make it too complex or the user friendliness will suffer. Some testing with users will clarify what is acceptable and often get you some "new ideas" to consider. There will be a "flow" to the capturing of data/populating tables. Keeping you data capture in sync with the "business flow" adds to the user friendliness. If you get an awkward process for data capture, users will let you know, and you'll be encouraged to revise the data capture/population process.

    As for logging changes, the techniques can vary. I have seen a logger table that recorded date and time, who logged the record and 250 char of free form text. I could see having a few fields with specific names for assisting search and retrieval. Thinking and typing -things like
    -object involved (query, table, form, report, module, procedure)
    -nameOfObject
    -description
    -importance
    -dependency

    This could be a part of or related to a task/to do list with assignedTo, assignedDate, expectedCompletion. This could also be part of a QA set up with scheduled, testNo, Issues, AcceptedBy, newTask...

    For documentation --that is the longer term materials that are part of the application --you might consider Word, rather than the database itself. With Word you can capture screenshots and incorporate in documentation. Some organizations have templates/formats specific to documentation, and procedures for completion, acceptance and storage.

    Here is a sample logger function for illustration. This one writes to a filesystem file (not in the database).

    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : Logger
    ' Author    : jack
    ' Date      : 1/21/2009
    ' Purpose   : To write records to a LOG file using FileSystemObject.
    '
    'Parameters
    ' sLogName As String -- full path and file name of the log file
    ' sLogRec As String  -- record to be written to the log
    '
    ' NOTE: Each log record has a timestamp appended
    '
    ' Special Note/restriction:
    '***** Must set a reference to MICROSOFT SCRIPTING RUNTIME ***
    '---------------------------------------------------------------------------------------
    '
    Sub Logger(sLogName As String, sLogRec As String)
          Dim tslog As TextStream
          Dim fileLog As file
          Dim i As Integer
          Dim fso As FileSystemObject
    10       On Error GoTo Logger_Error
    
    20    Set fso = New FileSystemObject
    30    Set fileLog = fso.GetFile(sLogName) '"I:\wordtest\output\Results.log")
    40    Set tslog = fileLog.OpenAsTextStream(ForAppending)
    50    tslog.WriteLine Now() & vbTab & sLogRec
    60    tslog.Close
    
    70       On Error GoTo 0
    80       Exit Sub
    
    Logger_Error:
    
    90        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure Logger of Module ADO_Etc"
    End Sub
    Here is another, used to assist in "what have we been working on recently" -- was helppful when there were several small database projects for a variety of users. (This gave some indication of recent activity)

    Code:
    Function fJLogIT(sActivity As String)
    'write a record into an access log file called jAccessLog.Log
    'to indicate what files/databases have been used recently
    'written Mar 2000
    'jed
    'Parameter:
    'sActivity      a short text about activity in this current database, can be null
    
    Open "E:\Work_DATA_20071207\C_Drive_WORK\Jack\WorkInProgress\jAccessLog.log" For Append As #1
    
    Print #1, Now() & vbTab & CurrentDb.Name & vbCrLf & vbTab & "--->  " & sActivity
    
    
    Close #1
    End Function
    Note: The log files could be Access tables. By using the Filesystem it was easy to write from a variety of databases. Pretty crude but was effective and useful - especially when someone asked --what has been going on in database area.

  7. #7
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    You are correct, I need to setup composite keys to prevent duplicates. As it is now, a user can add a room to a customer as many times as they want. I haven't set this up yet.

    I'll try to clarify what I'm trying to do here with my forms.

    I have customer information, building information (building name), room information (room name, room security), cabinet information, and switch information. I need to be able to add/remove records from all of these data groups.

    Currently, I have a form titled frmMainCustomers which displays customer information. I have a subform for facility manager (building name) and a subform for rooms. My rooms subform displays building name, room name, and room security method. This works fine. However, it does not display cabinet information or switch information.

    Each room most likely has a switch, although its possible that a room can have no switches. This switch is likely inside a cabinet but its possible that it is not. Therefore, I need to display cabinet information for each room as well as switch information. And whether that switch is inside a cabinet or not inside a cabinet. My problem is that if a single customer is shown, that customer can have numerous rooms (displayed in datasheet view). Without using subdatasheets, I do not know how to link cabinet information to my rooms table. And in turn, switch information to cabinet table. One customer shown will display numerous rooms, so which room has which cabinet? this is confusing to me.

    I can create a subform within a subform, but that might be confusing for the user. An idea I had was to have hyperlinks in my subrooms subform datasheet which opened up a popup form displaying the cabinets and switches within the cabinets. My problem with that is I do not think it would be easily search-able.

    Thus, I have thought to create a form which displays room information and then displays customer and cabinet/switch information in subforms. My problem here is that My main form needs to contain the customer Id from my CustomersToRooms table else it will not allow me to link my subform to the main form. If I did that, it will only display rooms which are currently associated to other customers.

    After much thought, I realize I can create a popup form which adds customers to rooms and so when I exit the popup form, it will display that room name in my main form. I'm going to give that a try...

  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,870
    How much of the database populating will have been done when you make the database available to users?
    What exactly will the users be doing in a typical day?
    Seems you are getting into the nitty-gritty and looking at options --good stuff.

  9. #9
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    At the time the database is presented to the users, 100% will be populated. However, situations do change. Room numbers change, equipment names change, equipment can be moved, customers can move to different locations, become the POCs of different rooms, or simply retire and no longer be a customer.

    That said, the database is primarily for viewing information easily. That is, "I need to get to this building, who should I call?" Or "Where is this switch located?" However, it will also need to allow information to be changed. From what little experience I have working with Access, I think it best to create forms/subforms primarily for viewing information and create popup forms for adding/removing information.
    Attached Files Attached Files

  10. #10
    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,870
    These things are definitely Events (a point where something changes and needs to be reflected in the database)
    Room numbers change
    equipment names change
    equipment can be moved
    customers can move to different locations
    become the POCs of different rooms
    retire and no longer be a customer.

    (new bldgs acquired/built/remodelled)
    (cabinets moved from/into a room)

    It's probably a good time to break each of these down (decompose them) into exactly what is involved, what has to change, what is impacted. You will use this logic to write and test code that modifies record(s) in table(s). You can look at these as transactions --made up of a series of steps to complete a defined change.

    The second part of your latest post deals with selecting/retrieving(reading and presenting) info from the database. Forms and subforms might be involved, but will likely involve other constructs like comboboxes and cascading comboboxes and others. See this for a sample search form.

  11. #11
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    Thank you for your help. I do have a list of test queries that I did. Also I ran several test scenarios. I.E. add a room, delete a room, change room name, etc.

    I'm attaching what I have so far. if you open up my navigation form, click on the rooms tab. Its a little ugly now but I'm working on cleaning it up. I still need to create popup forms that will add rooms, buildings, etc. I've decided it to display all the information in the respective forms, and then place a search form in the form header where you see frmMainRooms (I'll delete that label). And then, likely as this form serves more purpose than my customers form, I'll delete my customers form.

    BuildingsSwitches3 (6).zip

  12. #12
    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,870
    Glad it is doing what you want. I'm not sure what the form is doing, but I'm sure it will be more evident as you get done with the cleanup.

    For test data, it sometimes helps clarify your intention when your sample names/values are along the lines of: Buildings Bldg1, Bldg200 etc; and Rooms RoomA, Room9 etc.
    FacMgr1, Cust_Bob, Cstmr_Tom --just makes tracking things a little easier. (not essential, just a little more helpful for someone who doesn't know the application).
    It helps the user friendliness if you have a consistent method for Adding/Modifying/Deleting to each of the tables.

    For testing it good to write down your scenarios:
    eg
    Add Customer Cust_Rick who will be a POC for Room R-900 in BldgKK.
    Add Switch SW-200 to Room R-900 in BldgKK and put in a new Cabinet Cab-CC

    Some scenarios may not be logical and needs to be validated--eg there may not be a Room X in Bldg Y; a Room may already have a POC, moving a Cabinet from Room R300 to Room RmXYZ ;Moving a switch.....

    whatever makes sense. It's good to record what the steps for each of your scenarios "should be", and what you find when you actually go to do it in code "the actual/observed", then reconcile and see if there is a pattern that can be applied to similar activieties (Add/Modify/Delete..).
    Also, DELETEs are special. If you need to keep records fro history/auditors/finance??? you may consider a field on record say IsDeletedYN -- you set the field to Yes when the record is deleted. This is called a logical delete. The record exists, but is flagged as deleted --all info remains for those who need it. This set up requires you to be aware of the IsDeletedYN field in queries and procedures--
    you select "active" records where isDeletedYN <> "No"

    Good luck with your testing and cleanup.

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

Similar Threads

  1. Replies: 11
    Last Post: 05-13-2015, 11:10 PM
  2. Replies: 5
    Last Post: 11-13-2013, 10:02 AM
  3. Replies: 17
    Last Post: 08-22-2013, 08:22 AM
  4. Replies: 2
    Last Post: 11-28-2012, 10:32 AM
  5. Replies: 2
    Last Post: 11-13-2012, 02:11 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