Selasa, 28 April 2026

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

Hi Dean,
Glad to hear you got this sorted out.

It looks like you are storing multiple attendee values in a single field. This goes against basic normalization rules. Typically, there would be a related child table that would store one attendee per record. If your current table structure works, then  continue on. I have found these multi-value fields very limiting when considering future functionality.

I like your control named "txtlistresults". You might want to consider changing some other control names in the future to make your application more "self-documented".

Regards,
Duane


From: Dean Waring
Subject: 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:  Duane Hookom 
Sent: Sunday, April 26, 2026 10:42 AM
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?

Tidak ada komentar:

Posting Komentar