Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42
  1. #16
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    OK didn't get Dmax to work anyway

    Not entirely sure what you mean however it is not possibly to identify all equipment that is going to be inspected for a given inspection. Some equipment may be added later or another piece of equipment may need to be inspected that was not known at start of inspection



    At the moment an inspection is created (or a current inspection is opened) and the user can add equipment to it one by one

    Thanks

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    That's why I said user would have to select the Inspection and the Equipment (as in a single item) to create the checklist/answer records for.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    Yes that is what is occurring at the moment and this is how questions are poulated on frmChecklist after user selects inspection and then adds equipment to it...

    I will therefore keep trying with your code in the onclick section of addequipment to checklist button (cmdOpenChecklist) however this button already has a macro that poulates the questions and is only way I can get it to automatically display questions and make form visible (I cannot get this to work with vb code)

    I will just need to save this macro and run from code at same time

    Thanks

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I am confused.

    You already have code that saves a full set of checklist records for selected equipment? Where might I find that code in your project?

    You want to know how to also save the answers from previous inspection to these new checklist records?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    At the moment the user selects or adds an inspection (frmInspections) and then selects a piece of equipment to inspect (frmEquipment) when the cmdOpenChecklist is clicked (frmEquipment) the check-list is populated with all the questions for that equipment type (frmChecklist) and when completed all the answers and questions are saved into results table (frmChecklist) and that is working.

    What I want to do is (if equipment has been inspected before) display the last answer in AnswerID field so the user does not have to change it if same, however can change it if required, it is simply displaying this default (last answer) value that is giving me trouble

    Let me know if we are on same page with this one

    Thanks

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I think I understand and I am looking at those forms but I don't see a cmdOpenChecklist.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    here is latest version it is in frmEquipment (subform)

    Attachment 4817

    Cheers

  8. #23
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    Here is latest version with indenting, I have been requested to clean-up code (if this helps at all)

    Thanks

    Attachment 4818

  9. #24
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Indenting code does help with readibility.

    The cmdOpenChecklist code only executes a macro that makes subform visible. Could be all VBA with:
    Me.frmChecklist.Visible = True

    I still don't see implemented code that creates a complete set of checklist records for a piece of equipment. I did find Sub txtTest where you have my suggested code and I see the query I formed. Now the dilemma is where to put this code. I would think in cmdOpenChecklist, just before the line that makes the subform visible. Something like:
    Code:
    Private Sub cmdOpenChecklist_Click()
        Dim x As Integer
        If IsNull(DLookup("InspectionID", "qryChecklistAnswer", "InspectionID=" & Me.InspectionID & " AND EquipmentID=" & Me.EquipmentID)) Then
            x = Nz(DMax("InspectionID", "qryChecklistAnswer", "EquipmentID=" & Me.EquipmentID),0)
            If x <> 0 Then
                DoCmd.SetWarnings False
                DoCmd.RunSQL "INSERT INTO qryChecklistAnswer (InspectionID, EquipmentID, ChecklistID, AnswerID) SELECT " & Me!InspectionID & " AS InspectionID, EquipmentID, ChecklistID, AnswerID FROM qryChecklistAnswer WHERE InspectionID =" & x & " AND EquipmentID=" & Me!EquipmentID
                DoCmd.SetWarnings True
                Me.frmChecklist.Requery
            Else
                MsgBox "No prior inspection for this equipment."
            End If
        End If
        Me.frmChecklist.Visible = True
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #25
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    The cmdOpenChecklist code only executes a macro that makes subform visible. Could be all VBA with:
    Me.frmChecklist.Visible = True
    This is not entirely true the macro also goes to the control (frmChecklist)

    This not only makes the form visible it also displays all of the questions in the combo boxes without having to manually click on the form. Trust me I tried to do this with VBA however for some reason it does not work with vba code including setfocus, gotocontrol, or many other techniques I tried and if I try your code to make it visible it doesn't work either. Not sure why as I use this many times through my db maybe it is conflicting with the dynamically created subform... This is besides the point though as it works with the macro so it doesn't really need to be changed

    Back to the problem at hand I have put your code into the onclick code for the cmdOpenChecklist and unfortunately it doesn't do anything, is it working at your end, I tried inserting the code before and after the macro?


    Thanks

  11. #26
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    OK still stuck on this one, however giving up for the day

    attached is my most current version

    Any tips in meantime and help with my current issues still required is appreciated

    Thanks, I'll be back soon

    Attachment 4825

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I tested the SQL action code in a general sub using literal values. The INSERT SELECT works. I just can't get your form to work. When I click Edit Inspection I then select an inspection at random and frmEquipment opens but the Equipment combobox has no value and the droplist is empty. How do I select an equipment to add to an inspection?

    I also got this code to work:
    Me.frmChecklist.Visible = True
    Me.frmChecklist.SetFocus

    The focus goes to the EquipInspectID textbox. Since this is bound to an Autonumber field and not editable, should either make it not visible or set TabStop to No. Same for all Autonumber controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #28
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    I tested the SQL action code in a general sub using literal values. The INSERT SELECT works. I just can't get your form to work. When I click Edit Inspection I then select an inspection at random and frmEquipment opens but the Equipment combobox has no value and the droplist is empty. How do I select an equipment to add to an inspection?

    The combo in frmEquipment is dependant on client before it can be populated, therefore you need to select a client on frmMainMenu and then add or edit inspection before you can select a piece of equipment

    I to have been trying to figure this out and it gets as far as finding the last Inspection the Equipment was involved in however in and I got it to return the value in variable in msgbox but doesn't seem to populate/ display the answers

    Thanks

  14. #29
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Tried that. Selected the only site offered. Still get an empty combobox.

    I have to say this is one of the more confusing projects I've worked with.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #30
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    If you select Example Client 3 as client you should get a few options in the combo box here is latest version

    You are sure right it is confusing it is a combination of many people's advice and me trying to make it work. Believe me I am more confused than anyone

    I really appreciate your help

    Thanks
    Attachment 4831

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Default Min & Max Date Values in Form
    By alsoto in forum Forms
    Replies: 3
    Last Post: 10-03-2011, 10:54 AM
  2. Default Values in a form
    By handjor in forum Forms
    Replies: 3
    Last Post: 08-03-2011, 09:11 AM
  3. Replies: 8
    Last Post: 05-25-2010, 04:50 AM
  4. Last matched item in an unmatching query
    By kabaa01 in forum Queries
    Replies: 0
    Last Post: 05-19-2010, 03:46 PM
  5. Default Values
    By twainscott in forum Programming
    Replies: 0
    Last Post: 09-14-2006, 11:18 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