Share via

Remove RowSource from listbox when form closes

Anonymous
2024-04-06T17:43:05+00:00

In my Form Close event I have the following code. Problem is that it does not remove the RowSource. Am I missing something?

Private Sub Form_Close()

[Forms]![frm\_Navigation]![NavigationSubform].[Form].[Form]![lst\_Club].RowSource = "" 

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-06T18:47:51+00:00

    Actually did not reject them I had just posted and saw the second reply. In investigating that solution I realized that while I had removed the rowsource in design view without giving it enough thought after opening the form, I was right clicking on the form and going back into design view without going back to the listbox and removing the rowsource.

    Was this answer helpful?

    0 comments No comments
  2. George Hepworth 22,855 Reputation points Volunteer Moderator
    2024-04-06T18:31:33+00:00

    But, did you TRY them before rejecting the suggestions....

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-04-06T18:26:51+00:00

    Not sure that's he way to go in my case. This database uses SQL Server as the backend and the form is populated from a Pass Through query to an SQL Stored Procedure. I run the Passthrough query when the form opens and then set the RowSource for the listbox. The problem is that if the RowSource is not cleared when the form closes, the next time it opens I get an ODBC error.

    Was this answer helpful?

    0 comments No comments
  4. HansV 462.6K Reputation points
    2024-04-06T18:24:17+00:00

    Alternatively, leave the Row Source of the list box empty in design view, and set the Row Source in the On Load event.

    Was this answer helpful?

    0 comments No comments
  5. George Hepworth 22,855 Reputation points Volunteer Moderator
    2024-04-06T18:07:11+00:00

    Have you tried saving the design change to the form before closing it?

    Was this answer helpful?

    0 comments No comments