Senin, 27 April 2026

Re: [MSAccessProfessionals] Returning to a specific record on an access form from another access form

Thank you for your reply, and I apologize for my vague problem description. However, I believe that I was able to find a fix based on your questions. Below is some of the code. You may have a better solution. The issue appeared to be that I was re-opening the main form causing it to go to record 1. Here is what I came up with:

Main form, frmOGS, control launches new form with listbox:

 

Private Sub Command6_Click()

DoCmd.OpenForm "frmTDAttend", acNormal

End Sub

 

frmTDAttend listbox:

 

Data source for listbox:  list0= SELECT qryAttendees.[Full Name] FROM qryAttendees;

Multi Select = Simple

 

CmdSelect:

 

Private Sub cmdSelect_Click()

Dim varItem As Variant

    Dim strSelected As String

    Dim ctrl As Control

   

    Set ctrl = Me.List0

   

    If ctrl.ItemsSelected.Count > 0 Then

        For Each varItem In ctrl.ItemsSelected

             strSelected = strSelected & ctrl.ItemData(varItem) & "; " & (Chr(13) + Chr(10))

        Next varItem

       

        ' remove leading comma

      

        strSelected = Left(strSelected, Len(strSelected) - 2)

       

       ' assign value list to hidden text box control

      

       Me.txtlistresults = strSelected

      

       

       

        Debug.Print strSelected

      

    Else

        MsgBox "Noitems selected", vbInformation, "Warning"

    End If

   

    

    DoCmd.OpenForm "frmOGS", acNormal

    [Forms]![frmOGS].[TD Invitees] = strSelected

        DoCmd.Close acForm, "frmTDAttend", acSaveYes

End Sub

 



Dean J. Waring

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of Duane Hookom via groups.io <duanehookom=hotmail.com@groups.io>
Sent: Sunday, April 26, 2026 10:42 AM
To: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Returning to a specific record on an access form from another access form
 
I’m not sure what you mean by “launches a list box control”. Are you opening a new form that contains the list box?  Does your main form remain open? Is the new form opened in dialog mode? 

We would need to see some code. It seems like you have a requery in your code that would reset the main form’s position to the first record. 

Duane Hookom 


Sent from my mobile

On Apr 26, 2026, at 8:34 AM, Dean Waring via groups.io <deanjw2006=msn.com@groups.io> wrote:


I have a main form with a control that launches a list box control. The list box is a multi-select box. Once the user selects the required choices, they select a button on the listbox form to execute the selections. The code iterates through the selections and populates a textbox on the listbox form. The textbox assigns the value to a variable that populates the main form correctly; however, when I close the listbox form, it returns to the first record in the main form instead of the record updated. How do I get the listbox form to close and return to the calling record on the main form?

Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android

Tidak ada komentar:

Posting Komentar