473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Code to Changing a property in the table design view

Hi i was given the following advise,below my OriginalQuestion

I am a little new to ADOX can you direct me to the following
Do i place the code behind a button on a form?
Or do i place it in the On Open event and have a the default 10% and
give the user the option to change it to 0%

I have referenced th appropriate library and the default value of the
field to change is 0.1

My original question is

I want to do the following

A user decides if they want all orders reports etc to include 10% tax or
0% tax

Now i have set the default value in my [TAX]field in the tblOrders to .1
(10%) if i go back to the tbl in design view and change this to 0% all
works well.
I now want to somehow; allow the user to change this from a form as the
user has no access to the design view.

Can i call the default value in the tblOrders design view or any ideas

Regards

DD
This was the advise given
Posting Via Google so not sure if someone's already answered...

Using DAO

check out the defaultvalue property of the field object.

eg
in the debug window

?Currentdb.Tabledefs("Orders").Fields("Tax").Defau ltValue

Using ADOX
dim cat as ADOX.Catalog
'open your catalog

Set cat = New ADOx.Catalog
cat.ActiveConnection = strConn

catalog.tables("Orders").columns("Tax").Properties ("Default").Value

Reference the relevant library and hit F2 and check out the various
objects you can use.

Peter
DD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
5 2444
Hi David,

I'm a little confused by what you are trying to do.

Is the tax a global setting for the application (with or without GST I
presume) or is it applied to each transaction? I presume it's global.

If applied to each transaction why not use the default property of the
control (assuming you are displaying the tax on the user interace).
Store this value in a table or registry (using SaveSettings|GetSetting
or somesuch).

Using ADOX (you must be using MDAC 2.6 or later otherwise err 3241
appears).

On a form not bound to Orders
Put a command button on the form

Option Compare Database
Option Explicit

Public sub ChangeDefault_Click()

Dim cat As ADOX.Catalog

Set cat = New ADOX.Catalog
'change the conn string or use the current connection string
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\YourMDB.mdb;Persist Security Info=False"

cat.Tables("Orders").Columns("Tax").Properties("De fault").Value = 0

End Sub

Of course the table cannot be locked or opened by any users to do
this.

You don't need to go into design view to manipulate the database|table
schema.

Anyways that's the basics of how to do it. I am sure you can expand
upon it.

It should be realitively straightforward to work out that
?cat.Tables("Orders").Columns("Tax").Properties("D efault").Value
is a give away that the assignment
cat.Tables("Orders").Columns("Tax").Properties("De fault").Value = 0
is possible.

Peter

David Deacon <da**********@bigpond.com.au> wrote in message news:<40***********************@news.frii.net>...
Hi i was given the following advise,below my OriginalQuestion

I am a little new to ADOX can you direct me to the following
Do i place the code behind a button on a form?
Or do i place it in the On Open event and have a the default 10% and
give the user the option to change it to 0%

I have referenced th appropriate library and the default value of the
field to change is 0.1

My original question is

I want to do the following

A user decides if they want all orders reports etc to include 10% tax or
0% tax

Now i have set the default value in my [TAX]field in the tblOrders to .1
(10%) if i go back to the tbl in design view and change this to 0% all
works well.
I now want to somehow; allow the user to change this from a form as the
user has no access to the design view.

Can i call the default value in the tblOrders design view or any ideas

Regards

DD
This was the advise given

Nov 12 '05 #2
Hi Peter
thanks for all your help
I have to go back and re-think as i know find out that the GST can vary
on items from 10% to 0% so i will need to have a global setting that
then if a item is 0% then i can override the global setting in my Order
form
My tblOrdersDetail at this stage calculates the GST after the Extended
amount, i will need to have the GST in each linetotal and then i am
going to want it to default to 10% and maybe work it so if GST is 0 then
you place a -10% or something like this

As for ADOX what is MDAC is this a developers edition?? or ??
I am yet to buy the DEdition but will be!

Can i get back to you if i get stuck as you seem to know alot about this
side of things
DD

DD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Hi David,

You're welcome.

MDAC is the anacronym for Microsoft Data Access Components.
Essentially these components are the MS librarys for database
connectivity.

It is part of the MS operating system (well the recent ones anyhow).

you can check you MDAC version using CC.exe from Microsoft.

see http://support.microsoft.com/default.aspx?kbid=301202 on how to do
this.

This will also show you the relevant files involved.

Normally when storing data don't store calculated values (in
transactional system anyways). Instead of storing RawAmount, TaxRate,
BillAmount or somesuch store the RawAmount and TaxRate. Use a
calculation to get the BillAmount when displaying it on the user
interface (forms, reports).

If you are going to use a global default for the application that the
use can manipulate i'd save the value in the registry and make a
wrapper function to retrieve the value. However other may have
different suggestions.

You may wish to get the user to set the default but they need to
select either 0 or 10% for each line of the order, unless the whole
order is GST Inclusive/Exclusive then you will need to store the Tax
Rate on the Order Header and apply it to the order total (ie the sum
of the lines).

I don't check my email account too often (it's a spam trap really, but
feel free to contact me) and the best policy is to post your questions
to the NewsGroup as there is an amazing amount of knowledge in
everyone's collective head.

Regards,

Peter

David Deacon <da**********@bigpond.com.au> wrote in message news:<40***********************@news.frii.net>...
Hi Peter
thanks for all your help
I have to go back and re-think as i know find out that the GST can vary
on items from 10% to 0% so i will need to have a global setting that
then if a item is 0% then i can override the global setting in my Order
form
My tblOrdersDetail at this stage calculates the GST after the Extended
amount, i will need to have the GST in each linetotal and then i am
going to want it to default to 10% and maybe work it so if GST is 0 then
you place a -10% or something like this

As for ADOX what is MDAC is this a developers edition?? or ??
I am yet to buy the DEdition but will be!

Can i get back to you if i get stuck

Nov 12 '05 #4
Thanks Peter
I have got your global setting on TAX working great, i could leave the
gst out of the line total but i cant for the long term vision.
I am going to look at the idea of using your suggestion

If you are going to use a global default for the application that the
use can manipulate i'd save the value in the registry and make a
wrapper function to retrieve the value. However other may have
different suggestions.

Could you give me an idea on how to do this

Regards
DD
DD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Hi David,

Option Compare Database
Option Explicit

const USER_DEFAULTS = "UserDefaults"

Public Function SaveUserDefault(ByRef pstrDefault As String, ByRef
pvarValue As Variant) As Boolean

On Err GoTo err_Handler

'i'd also make a wrapper for YourAppName
SaveSetting "YourAppName", USER_DEFAULTS, pstrDefault, pvarValue

SaveUserDefault = True

exit_Handler:
Exit Function

err_Handler:
MsgBox Err.Number & " : " & Err.Description, vbCritical
Resume exit_Handler

End Function

Public Function GetUserDefault(ByRef pstrDefault As String) As Variant

On Err GoTo err_Handler

GetUserDefault = GetSetting("YourAppName", USER_DEFAULTS, pstrDefault,
0)

exit_Handler:
Exit Function

err_Handler:
MsgBox Err.Number & " : " & Err.Description, vbCritical
Resume exit_Handler

End Function

' End code

In the debug window to test
?SaveUserDefault("TaxRate", .22)

?GetUserDefault("TaxRate")

is a suggestion. I'd do a search on google and see if you can dig up
any discussion on the pro's and con's of using this method vs. tables
vs. custom database properties (not the way to go IMO for user
settings if you are replacing the front end regularly (ie in a
corporate environment and 'trickling' down changes).

Of course you don't need to make wrapper function, just use
SaveSetting and GetSetting directly in your code. Just if you change
the method (ie decide to use tables or some other method) to save|get
later on it's easy to change the code in the wrapper than have to
change all the code embedded in the rest of your code with sometimes
unpredictable results.

Regards,

Peter

David Deacon <da**********@bigpond.com.au> wrote in message news:<40***********************@news.frii.net>...
Thanks Peter
I have got your global setting on TAX working great, i could leave the
gst out of the line total but i cant for the long term vision.
I am going to look at the idea of using your suggestion

If you are going to use a global default for the application that the
use can manipulate i'd save the value in the registry and make a
wrapper function to retrieve the value. However other may have
different suggestions.

Could you give me an idea on how to do this

Regards
DD
DD

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Deano | last post by:
Hi, I need to disable a command button at some point. Easy enough. Initially in design view it is set as enabled. Now once I disable it, how can I ensure that when the app is restarted, the...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
1
by: David Deacon | last post by:
Back again I want to do the following A user decides if they want all orders reports etc to include 10% tax or 0% tax Now i have set the default value in my field in the tblOrders to .1...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
0
by: Ziyad Makki | last post by:
Hello, I have created a Web Composite Control. I have also created a designer class that is used to render the control at design time. All though it dose work, I have been experiencing some...
5
by: et | last post by:
How do I get Visual Studio to quit modifying the layout of my code? In Tools, Options, Text Editor, All Languages, Tabs, I have set to None. In HTML/XML, I have tabs set to none; all automatic...
11
by: Tim Marshall | last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users to pick colours for various control properties in certain apps. Is there a way to take the colour code that is displayed in...
1
by: Jim M | last post by:
After learning that the 'subdatasheet name' property set to "" can adversely effect database speed, I wanted to send a small code snippent to my end users to reset the SubdatasheetName Property so...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.