Results 1 to 8 of 8
  1. #1
    GaryShelton is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    4

    Open Form and goto record with Listbox selection

    I am trying to open a form and navigate to a record. Here is the code:



    Private Sub btnPoolDetails_Click()
    On Error GoTo btnPoolDetails_Click_Err

    Dim PoolNumber As String

    If Me.lbxCustomerPoolList.ListIndex < 0 Then
    MsgBox "Select a Pool from list"
    Else
    PoolNumber = Me.lbxCustomerPoolList.Column(1)
    End If
    MsgBox "[tbl1Pools]![ID]=" & PoolNumber
    DoCmd.OpenForm "frm1AllPoolsDetails", acNormal, "", "[tbl1Pools]![ID]=" & PoolNumber, , acNormal


    btnPoolDetails_Click_Exit:
    Exit Sub

    btnPoolDetails_Click_Err:
    MsgBox Error$
    Resume btnPoolDetails_Click_Exit

    End Sub

    The message Box returns the proper ID, however I get a parameter request asking for a PoolNumber with the correct Poolnumber in the message
    Click image for larger version. 

Name:	Capture.JPG 
Views:	16 
Size:	13.3 KB 
ID:	36797

    any Help??

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Does the form's recordsource contain the field P04C0009? If not, it would cause the parameter request.

  3. #3
    GaryShelton is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    4
    No the P04C0009 is the ID in the record table

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Can you post a copy of the database? We don't need all the data, just enough to highlight this issue and instructions to get to and understand it.

  5. #5
    GaryShelton is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    4
    I am just getting started with Access and think this should be a simple implementation, one I can see using often so I must simply be missing something.

    Just 2 steps:

    1) Open a Form from another one, no problem there
    2) Filter the second form, or even navigate to a record with a value from the first one. Where that value comes from shouldn't matter.
    In this case I get it from a ListBox column and can verify that through the msgBox function.

    My second form has a table as it's record source and I want to filter/find a unique index "ID" of P04C0009

    Thanks for the help


  6. #6
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    PoolNumber is text and it must be between single quotes.
    You have to say: DoCmd.OpenForm "frm1AllPoolsDetails", acNormal, "", "[tbl1Pools]![ID]='" & PoolNumber & "'", , acNormal

  7. #7
    GaryShelton is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    4
    The single quotes were it!! Thanks so much. I knew it was something simple I was missing. I have worked in Delphi up until now so the Quote double quote sometimes () sometimes not can be confusing. As well as my failing eyesight, probably looked at examples and missed the single quote betwen the doubles.

    Thanks again!

  8. #8
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    You are welcome!

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

Similar Threads

  1. Using search form with listbox to goto record
    By dweekley in forum Access
    Replies: 2
    Last Post: 05-04-2017, 01:31 PM
  2. Replies: 3
    Last Post: 11-22-2015, 11:01 AM
  3. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  4. details form open from listbox selection
    By accesshelpme in forum Access
    Replies: 9
    Last Post: 05-18-2012, 10:50 AM
  5. Replies: 1
    Last Post: 02-01-2012, 11:27 PM

Tags for this Thread

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