Results 1 to 7 of 7
  1. #1
    raphael99 is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    13

    Open form from a listbox

    I use:

    DoCmd.OpenForm "My second form", , , "Customers = '" & Me.listbox name & "'"

    for open a second form from a list box . It is working but when I open the second form it opens the first record of same customer name.
    In example:
    Marion Bette
    Marion Dave
    Marion Junior


    When I click on on Marion Bette it opens the right record: Marion Bette
    When I click on Dave or Junior it still opens Marion Bette record.
    Can anyone please help?
    Thanks

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I think that your problem may be with:
    Me.listbox name
    Perhaps you need to refer to the combo box column that will match with the field "Customers". Maybe something like
    Me ComboxName(1)
    Is "Customers" a Primary Key field.
    What is the SQL Row Source of the combo box
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    raphael99 is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    13
    Row source is a query.
    Me.listboxname(1) does not works.
    I 'm not sure what you mean for primary key field (I have an ID but that is not included in the query)

    Thanks for your reply

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Please show the SQL statement of the query
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    raphael99 is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    13
    SELECT tblAnagrafica.Cognome, tblAnagrafica.Nome, tblAnagrafica.Indirizzo, tblAnagrafica.Comune, tblAnagrafica.[Tessera Sanitaria], tblAnagrafica.[Codice Fiscale], tblAnagrafica.ID
    FROM tblAnagrafica
    WHERE (((tblAnagrafica.Cognome) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((tblAnagrafica.Nome) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((tblAnagrafica.Indirizzo) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((tblAnagrafica.Comune) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((tblAnagrafica.[Tessera Sanitaria]) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((tblAnagrafica.[Codice Fiscale]) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*"));

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    So which column in tblAnagrafica will be = to Customers
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    raphael99 is offline Novice
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    13
    Customers = Cognome

    Anyway i solved asking around and the solution (the working one) is :

    DoCmd.OpenForm "My second form", , , "ID = " & Me.listbox name.Column(6)

    where (6) is the ID column number in the listbox
    Hope this help some others

    Thank to you.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-23-2014, 03:32 PM
  2. Listbox Open Form with VBA
    By phineas629 in forum Forms
    Replies: 3
    Last Post: 04-08-2014, 02:28 PM
  3. Double click on listbox to open up form
    By EthanMoist in forum Forms
    Replies: 14
    Last Post: 05-21-2013, 02:10 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: 29
    Last Post: 02-13-2011, 01:21 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