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.