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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:17:20+00:00 2026-05-12T00:17:20+00:00

I have a query in VBA that Adds a few columns to a table.

  • 0

I have a query in VBA that Adds a few columns to a table. How can I change the format of the PercentSuccess column to Percent using SQL in VBA?

Here is the code I’m using to add the columns.

strSql5 = " Alter Table analyzedCopy3 " & _   
   "Add Column PercentSuccess Number, Success Number, prem_addr1 TEXT(50) "

DoCmd.SetWarnings False   
DoCmd.RunSQL strSql5   
DoCmd.SetWarnings True

I’ve tried to use Format() but I can’t get it to work for changing what I need to change. It only seems to change the things like Number, Text and so on.

  • 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-12T00:17:21+00:00Added an answer on May 12, 2026 at 12:17 am

    You cannot set the Format property using SQL but you can do it through additional VBA code. Also you should know that certain field properties do not actually exist until they are assigned a value of which the Format property is one of them. The code below first gets a reference to the field in question, creates a new Format property with the desired value, and then appends it to the fields definition. The Microsoft Access UI is misleading because it makes you think the property already exists.

      Dim db   As Database
      Dim tdef As TableDef
      Dim fdef As Field
      Dim pdef As Property
    
      Set db = CurrentDb()
      Set tdef = db.TableDefs("analyzedCopy3")
      Set fdef = tdef.Fields("PercentSuccess")
    
      Set pdef = fdef.CreateProperty("Format", dbText, "Percent")
      fdef.Properties.Append pdef
    

    Finally this code only works if you use the DAO objects; you cannot set this property using ADO.

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

Sidebar

Related Questions

I have a query that is created in VBA and selects column information from
I have the following query in VBA: DoCmd.RunSQL INSERT INTO table (value) VALUES ('example')
I am using in C# MYsql .I have query that works if I run
I've noticed that a few Wordpress blogs have query statistics present in their footer
I have a VBA function IsValidEmail() that returns a boolean. I have a query
I have an Excel VBA tool which needs to query Oracle. I am using
I have a rather simple PL/SQL query (...) DECODE(upper(Table.Column), 'SOMETHING', '---', TABLE2.COLUMN2) as VALUE
I have a list box that I populate with a Table/Query and select multiple
I'm generating a query and report through VBA. I have an option of asking
I have a query that is dynamically built after looking up a field list

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.