Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6545401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:34:53+00:00 2026-05-25T11:34:53+00:00

I am required to provide a way for users to choose which column they

  • 0

I am required to provide a way for users to choose which column they want to display from a table. The user has a combo box of column names in a form which they can select one of and then hit a button which opens a report. I wrote some code which creates an SQL query based on the user’s input, but it’s not being called. I’ve tried inserting MsgBox statements, asserts, etc., but it never gets called. If I use a macro instead, that will be run, but not this sub…

Private Sub Report_Open(Cancel As Integer)
    Dim field As String
    Dim sqlQuery As String
    Dim ctl As Control
    ctl = "Forms![RuleGroupForm]![selectRuleFieldCombo]"

    field = "rules.[" & ctl & "]"

    ' E.g. if the field was "Source File", the final query should look like this:
    'SELECT overview.ID, relationship.rulesID, rules.[Source File], overview.[Rule Group], rules.RulegroupID
    'FROM (overview INNER JOIN relationship ON overview.id=relationship.id)
    'INNER JOIN rules ON relationship.rulesID=rules.ID
    'WHERE rules.[Source File] IS NOT NULL;

    sqlQuery = "SELECT overview.ID, relationship.rulesID, " & field
    sqlQuery = sqlQuery & ", overview.[Rule Group], rules.RulegroupID"
    sqlQuery = sqlQuery & "FROM (overview INNER JOIN relationship ON overview.id=relationship.id) "
    sqlQuery = sqlQuery & "INNER JOIN rules ON relationship.rulesID=rules.ID"
    sqlQuery = sqlQuery & "WHERE " & field & " IS NOT NULL;"
    Me.RecordSource = sqlQuery
    Requery

    debugText = "New SQL Query = " & sqlQuery
End Sub

Thanks.

Edit: Resolved, not sure how to respond to own question…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:34:53+00:00Added an answer on May 25, 2026 at 11:34 am

    There are a few things to check, apart from close and open, when you get odd behaviour such as this in Access. One is to see if the event on the properties sheet for the form or report, Open in this case, still contains [Event Procedure] – occasionally a form or report can have the code, but the event is not marked. When developing, that is, adding forms, reports and code, it is a good idea to run Compact and Repair on a regular basis, this also means regular back-ups – a simple copy saves a lot of grief. Finally, when developing fairly regular Decompiles are a good idea. I keep a small script that I can drop the Access file on to run decompile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

required( dependency-expression ) They give an example of required: #other:checked but I want my
Is it required to call TemplateControl.ResolveUrl() before passing it to TemplateControl.LoadControl() ? Which way
My app will let users cut out things from photos. They'll be able to
To protect software, you can create a validation system which requires users to provide
Hy guys, we are developing a system which will provide users with access to
I'd like to provide my users a way to navigate a taxonomy by successively
When creating a designable .NET component, you are required to provide a default constructor.
As part of a project with a partner, we are required to provide single-sign-on
The iPad application I'm working on requires that the user provide a username and
I'm building a web application that requires users to provide their location (similar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.