Solved

Access Select Multiple Records on List and Transfer to Subform

Posted on 2009-05-12
9
342 Views
Last Modified: 2013-11-28
Greetings:

I have a main form (unbound)  that contains a list that is generated from several search fields.  Currently, I can click on the record, and press a command button that will copy that record information over to a bounded subform.  Works great!  However, looks like we would like to be able to select multiple record on the list and have those records be copied over to the subform for browsing.

Here is the code in the list table review subform(frmBrowseByName_Single):
Private Sub Command83_Click()
DoCmd.OpenForm "frmBrowseByName_Single", , , "[StructureID]=" & Me.lstStructures
On Error GoTo Err_Command83_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmBrowseByName_Single"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command83_Click:
    Exit Sub

Err_Command83_Click:
    MsgBox Err.Description
    Resume Exit_Command83_Click
   
End Sub

Here is the code in the subform (frmBrowseByName_Single):
Private Sub Form_Load()
'Used to allow for next record to be browsed
Dim rstFormRecords As Object
Dim lngStructureID As Long
   
    lngStructureID = Me.StructureID
    Me.FilterOn = False
   
    Set rstFormRecords = Me.Recordset.Clone
    rstFormRecords.FindFirst "[StructureID] = " & lngStructureID
    If Not rstFormRecords.EOF Then Me.Bookmark = rstFormRecords.Bookmark

End Sub

If I set the multiple select to extended, and the code stopped at the StructureID =.  

Thanks for the help!!

heather
0
Comment
Question by:Heather_D
  • 5
  • 4
9 Comments
 
LVL 5

Expert Comment

by:josephwalsh
ID: 24367007
Take the query that generates the list.
That is also the basis of your recordsource for the other form.

Therefore create your new query as follows (set this as the recordsource for the other form):
SELECT * FROM yourtablename/queryname
WHERE [StructureID] IN yourexisting searchquery
0
 

Author Comment

by:Heather_D
ID: 24407424
Hi Joseph,

Not sure I understand.  Here is my search query:

SELECT tblNCHPOsurvey.StructureID, LTrim([PropertyFirstName] & " " & [PropertyName] & " " & [PropertyTown]) AS NameandType, tblNCHPOsurvey.COUNTY, LTrim([LocationPrefix] & " " & [PropertyLocation] & " - " & [PropertyTown]) AS AddressTown, tblNCHPOsurvey.SSN, tblNCHPOsurvey.PropertyName, tblNCHPOsurvey.PropertyFirstName, tblNCHPOsurvey.PropertyTown, tblNCHPOsurvey.NRCODE, tblNCHPOsurvey.LocationPrefix, tblNCHPOsurvey.PropertyLocation, tblNCHPOsurvey.PropertyTown, tblNCHPOsurvey.Style, tblNCHPOsurvey.Material, tblNCHPOsurvey.Construction, tblNCHPOsurvey.Comment, tblNCHPOsurvey.Date, tblNCHPOsurvey.ListStatus
FROM tblNCHPOsurvey
WHERE (((LTrim([PropertyFirstName] & " " & [PropertyName] & " " & [PropertyTown])) Like "*" & [forms]![frmSearch]![txtNameandType] & "*") AND ((tblNCHPOsurvey.COUNTY) Like "*" & [forms]![frmSearch]![cmbCounty] & "*") AND ((LTrim([LocationPrefix] & " " & [PropertyLocation] & " - " & [PropertyTown])) Like "*" & [forms]![frmSearch]![txtPropertyLocation] & "*") AND ((tblNCHPOsurvey.PropertyTown) Like "*" & [forms]![frmSearch]![txtTown] & "*") AND ((tblNCHPOsurvey.NRCODE) Like "*" & [forms]![frmSearch]![txtNRCode] & "*") AND ((tblNCHPOsurvey.Style) Like "*" & [forms]![frmSearch]![txtStyle] & "*") AND ((tblNCHPOsurvey.Material) Like "*" & [forms]![frmSearch]![txtMaterial] & "*") AND ((tblNCHPOsurvey.Construction) Like "*" & [forms]![frmSearch]![txtConstruction] & "*") AND ((tblNCHPOsurvey.Comment) Like "*" & [forms]![frmSearch]![txtComment] & "*") AND ((tblNCHPOsurvey.Date) Between Nz([Forms]![frmSearch]![txtEarlyDate],[Date]) And Nz([Forms]![frmSearch]![txtLateDate],[Date])) AND ((tblNCHPOsurvey.ListStatus) Like "*" & [forms]![frmSearch]![cmbListStatus] & "*"))
ORDER BY tblNCHPOsurvey.COUNTY, tblNCHPOsurvey.PropertyName, tblNCHPOsurvey.PropertyFirstName, tblNCHPOsurvey.PropertyTown;

THanks,

Heather
0
 

Author Comment

by:Heather_D
ID: 24422927
Do you need a copy of the database?  

Any suggestions would be greatly appreciated!

Thanks,

Heather
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Heather_D
ID: 24423169
DoCmd.OpenForm "frmBrowseByName_Single", , , "[StructureID]=" & Me.lstStructures

If I change the list select to extended, I get an error in the above code.  Looks like it might have something to do with the structureid being = to something instead of multiple things.
0
 
LVL 5

Expert Comment

by:josephwalsh
ID: 24424199
A copy of the datbase would helpful.
Thanks
Joe
0
 

Author Comment

by:Heather_D
ID: 24424267
This is the database.  Go to switchboard form and click on search/browse by Name.  The search Name form (frmsearch)  is my original form and then when you click look record, that form is the subform(frmbrowsebyname_single).

expert-exchange.zip
0
 
LVL 5

Expert Comment

by:josephwalsh
ID: 24429774
Thanks
0
 
LVL 5

Accepted Solution

by:
josephwalsh earned 500 total points
ID: 24429811
I have attached an updated database.
JPW has been put in a comment where changes have been made.

I made changes to the search form.
The listbox has been changed to allow multiple select.
There is new code in 'View a Record' where it builds the filter for the subform.
Option explicit has been added to give more control over variable defs etc.

I made a few small changes to frmBrowseByName_Single to allow the filter to work correctly.

Regards,
Joe
expert-exchangenew.zip
0
 

Author Closing Comment

by:Heather_D
ID: 31580587
Super!! I love you!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question