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 8121087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:22:15+00:00 2026-06-06T05:22:15+00:00

I have a simple query tied to a command button that shows a summary

  • 0

I have a simple query tied to a command button that shows a summary of the values in a particular field. It’s running on a table that changes with each use of the database, so sometimes the table will contain this field and sometimes it won’t. When the field (called Language) is not in the file, the user clicks the command button and gets the “Enter Parameter Value” message box. If they hit cancel they then get my message box explaining the field is not present in the file. I would like to bypass the “Enter Parameter Value” and go straight to the message if the field is not found. Here is my code:

Private Sub LangCount_Click()
DoCmd.SetWarnings False

On Error GoTo Err_LangCount_Click

    Dim stDocName As String

    stDocName = "LanguageCount"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Err_LangCount_Click:
    MsgBox "No Language field found in Scrubbed file"
Exit_LangCount_Click:
    Exit Sub

     DoCmd.SetWarnings True
End Sub
  • 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-06-06T05:22:16+00:00Added an answer on June 6, 2026 at 5:22 am

    You can attempt to open a recordset based on the query before you run the query:

    Set rs = CurrentDb.QueryDefs("query1").OpenRecordset
    

    This will go straight to the error coding if anything is wrong with the query.

    Alternatively, if it is always the language field and always in the same table, you can:

    sSQL = "select language from table1 where 1=2"
    CurrentDb.OpenRecordset sSQL
    

    This will also fail and go to your error coding, but if it does not fail, you will have a much smaller recordset, one with zero records.

    You can easily enough get a list of fields in a table with ADO Schemas:

    Dim cn As Object ''ADODB.Connection
    Dim i As Integer, msg As String
    
        Set cn = CurrentProject.Connection
        Set rs = cn.OpenSchema(adSchemaColumns, Array(Null, Null, "Scrubbed"))
    
        While Not rs.EOF
            i = i + 1
            msg = msg & rs!COLUMN_NAME & vbCrLf
            rs.MoveNext
        Wend
    
        msg = "Fields: " & i & vbCrLf & msg
    
        MsgBox msg
    

    More info: http://support.microsoft.com/kb/186246

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

Sidebar

Related Questions

I have a simple query that increases the value of a field by 1.
I have a simple query: $query = new WP_Query('showposts=5'); that will obviously display 5
I have a simple query which is returning records based on the field status
I have a simple SQL query in PostgreSQL 8.3 that grabs a bunch of
I have a very simple query that's giving me unexpected results. Hints on where
I have a simple query that is suppose to take user inputted text and
I have a simple query that relies on two full-text indexed tables, but it
I have a simple query over a table, which returns results like the following:
I have a simple query running on both .NET 3.5 and .NET 4, something
I have a simple query in access which displays data from a single table.

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.