Open Detail Form via Unbound List Box

vapid2323

Scion
Local time
Today, 14:19
Joined
Jul 22, 2008
Messages
217
I have an unbound list box that is found in a SubForm. I want to use the following code to open a details box so a user can edit that list item in...Detail.

For some reason my code is not working I attempted to follow the article in this link: http://www.databasedev.co.uk/list_box_searching.html with no luck.

Code:
Private Sub lstMon_DblClick(Cancel As Integer)
'If the user double-clicks in the list open the details frm
If Not IsNull(lstMon) Then
        DoCmd.OpenForm "frmAphBedSlotDetail", , , _
                   "[tblBedSlot.id]=" & _
                   "'" & Me.lstMon.Column(0) & "'"
    End If
End Sub

To provide more information:

Main form = frmAphpgCapacity
Subform = frmAphBedslot

Unbound list is found inside frmAphBedslot and pulls records based on the main form.
 
Last edited:
If the field is numeric it would require a slightly different syntax:

http://www.baldyweb.com/wherecondition.htm


Thank you for that I will have to keep that site around!

I still get a error with this code... Not sure why, it pulls the value correctly. Datatype mismatch

Code:
Private Sub lstMon_DblClick(Cancel As Integer)
'If the user double-clicks in the list open the details frm
If Not IsNull(lstMon) Then
DoCmd.OpenForm "frmAphBedSlotDetail", , , "id = '" & Me.lstMon.Column(0) & "'"
End If
End Sub
 
Bah I got it

DoCmd.OpenForm "frmAphBedSlotDetail", , , "[tblBedSlot.id] = " & Me.lstMon.Column(0)
 
Glad it helped you.
 

Users who are viewing this thread

Back
Top Bottom