Results 1 to 5 of 5
  1. #1
    JayRab is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    78

    Open Form with set Equipment and max ID

    Open a form and find max ID and set value as that id.

    I currently have a form in datasheet view. They can click on ID and open a form to CLOSE the event. The code below pulls ID 1707 since that is what I clicked.
    Code:
    DoCmd.OpenForm "EquipmentUpFrm", , , "[ID]=" & Me.ID & ""
    I want them to be able to do the same thing if they Click the equipment string instead( red code example of how I want it to work obviously it doesnt.)

    The BLUE Code will pull up the sheet like I want...but it pulls up with the wrong ID. I need it to pull id 1707 and it pulls ID 404.



    Code:
    Private Sub Equipment_DblClick(Cancel As Integer)
    strCheck = Me.Equipment.Value
    strAvailability = Me.Availability
    Debug.Print (strAvailability) ' Check to see Availability
    If strAvailability = "UP" Then
    DoCmd.OpenForm "Equipment DownTime", , , "[Equipment]='" & Me.Equipment & "'"
    x = 0
    Do While x <= Forms![Equipment DownTime].Equipment.ListCount
    If Forms![Equipment DownTime].Equipment.ItemData(x) = strCheck Then
    Forms![Equipment DownTime].Equipment.ListIndex = x
    Exit Sub
    End If
    x = x + 1
    Loop
    
    
    Else
    DoCmd.OpenForm "EquipmentUpFrm", , , "[Equipment]='" & Me.Equipment & "'" 
    
    'DoCmd.OpenForm "EquipmentUpFrm", , , "[Equipment]='" & Me.Equipment & "' AND [ID]=Max(ID)"
    End If
    
    End Sub
    Any help with this would be apprecaited.

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    If your code above pulls up the correct ID, why can't the same code be used in the click event of equipment string if they are on the "same row of datasheet" ? Does it make sense ?
    You can use DMax to get max ID -
    Code:
    DoCmd.OpenForm "EquipmentUpFrm", , , "[Equipment]='" & Me.Equipment & "' AND [ID]=" & DMax("ID","yourTableName","[Equipment]='" & Me.Equipment & "'")

  3. #3
    JayRab is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    78
    Click image for larger version. 

Name:	DashBoard Click.png 
Views:	7 
Size:	59.4 KB 
ID:	15186
    The problem is the equipment ID string is in a different sub sheet. See pic above.

    Ill give your code a try and see how it goes.

    Only reason I am doing this is during training. The majority of the people wanted to click the top arrow instead of the bottom arrow. Once this code works I will get rid of the Maintenance work Request Hyperlink as well. Since again they just want to click in the Upper Colored areas to change Status and Availabilities.

  4. #4
    JayRab is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    78
    Got it working since you explained it, i remembered how I should do it. had a lapse. I just grabbed from the query i use for the first code with dlookup()

    Code:
    strid = DLookup("[ID]", "[Active/Open]", "[Equipment]='" & Me.Equipment & "'")
    DoCmd.OpenForm "EquipmentUpFrm", , , "[ID]=" & strid & ""
    Appreciate the help again.

  5. #5
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Glad to help. Mark it as solved.

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

Similar Threads

  1. Replies: 35
    Last Post: 01-08-2014, 01:33 PM
  2. Automation Equipment Tracker
    By cartotech81 in forum Database Design
    Replies: 5
    Last Post: 07-11-2012, 10:58 AM
  3. Break up equipment order on form
    By zimzala20 in forum Forms
    Replies: 6
    Last Post: 08-15-2011, 03:06 PM
  4. equipment and people check in and out
    By aaronlalonde in forum Access
    Replies: 0
    Last Post: 07-29-2009, 08:28 PM
  5. design equipment management
    By chanlongs in forum Database Design
    Replies: 0
    Last Post: 07-14-2009, 06:06 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