Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    55

    Lightbulb Unanswered: Opening records from Listbox

    Private Sub Command10_Click()
    On Error Resume Next
    DoCmd.OpenForm "frmEdit", , , _
    "[tblMain.RegoNo]=" & "'" & Me.lstSearchE.Column(3) & "'"

    End Sub


    I have the above code, which works fine for opening the corresponding records, however, when I ammend the code to the following:

    Private Sub Command10_Click()
    On Error Resume Next
    DoCmd.OpenForm "frmEdit", , , _
    "[tblMain.JobId]=" & "'" & Me.lstSearchE.Column(0) & "'"

    End Sub

    The code does nothing. The 'JobId' field is an 'autonumber' and a primary key, however, i don't think this is the problem. Can someone please, let me know why this code does not open the form 'frmEdit', and bring up the records where the 'JobId' in the list box matches that in the 'tblMain'.

    It is not a syntax problem! I know this for sure

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    If the JobID is an Autonumber field then it is a number. Therefore the quotes around the field name are not necessary.

    DoCmd.OpenForm "frmEdit", , , _
    "[tblMain.JobId]=" & Me.lstSearchE.Column(0)

  3. #3
    Join Date
    May 2005
    Posts
    119
    Sorry! I had this opened and someone else had replied before I posted! Anyway, I agree with the previous response (obviously).

    Try it without the single quotes..autonumber is a long integer field, so it doesn't need quotes.

    DoCmd.OpenForm "frmEdit", , , _
    "[tblMain.JobId]=" & Me.lstSearchE.Column(0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •