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

  • Home
  • SEARCH
  • 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 6120029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:37:18+00:00 2026-05-23T15:37:18+00:00

Scenario: I am creating an advanced search form for an access database. They already

  • 0

Scenario: I am creating an advanced search form for an access database. They already have single search forms that run access queries and open in the query window.

Problem: I’d like to mimic this functionality but I am looking to create the query as a string within the code and then open it in a query window. Is this possible? I have searched google but didnt find anything. If its not possible are there any alternatives?

Thanks in advance.

  • 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-23T15:37:18+00:00Added an answer on May 23, 2026 at 3:37 pm

    You can open a Form in datasheet view which looks like a query window but you need to create a form add the controls to it and then set the recordsource

    e.g.

    Dim rst As DAO.Recordset
    Dim rsField As DAO.Field
    Dim control As Access.TextBox
    
    Dim frm As Form
    Set frm = CreateForm()
    frm.Visible = False
    
    Dim sql As String
    sql = "Select * from MSysObjects"
    
    Set rst = CurrentDb.OpenRecordset(sql)
    
    
    
    For Each rsField In rst.Fields
        Debug.Print rsField.Name
        Set control = CreateControl(frm.Name, acTextBox, acDetail)
        With control
           .Width = 100
           .Height = 100
           .Top = 100
           .Left = 100
           .ControlSource = rsField.Name
           .Name = rsField.Name
    
        End With
    
    Next rsField
    
    Set rst = Nothing
    
    frm.Visible = True
    
    
    frm.RecordSource = sql
    
    DoCmd.OpenForm frm.Name, acFormDS
    

    There are a couple of problems with this.

    1. It creates a new form each time. This means when a user closes the form they’ll be asked if they want to save it. So you might want to investigate opening an existing form and modifying (clearing existing items)
    2. The query is executed twice. the first time to get the fields and the second to actually show the form. Depending on what the query does this may or may not be an issue.

    Honestly modifying a querydef is probably the saner way to go.

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

Sidebar

Related Questions

Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario: I have a directory on a server that hosts my website that contains
I have the following scenario: sub_1 can run immediately sub_2 can run immediately sub_3
Scenario: Creating an app for learning purposes and am trying to make it database
The scenario: I'm creating a login form for an MVC2 application. How i'm doing
Scenario is that we send out thousands of emails through SMTP server. Content is
Scenario: An event is raised in class A that needs to be handled by
Scenario I have two wrappers around Microsoft Office, one for 2003 and one for
Scenario: Let's say I have four very similar applications (i.e. most of the functionality
Scenario You've got several bug reports all showing the same problem. They're all cryptic

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.