473,385 Members | 1,331 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,385 software developers and data experts.

altering field properties in code

Is it possible to retrieve field properties from a table in access2000
using code?

I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as dao.property

set dbs = CurrentDb
set tbl = dbs.TableDefs(tableName)
set fld = tbl.Fields(fieldName)
set prop = fld.Properties(DataType)

debug.print prop.name
"
and I get Type Mismatch, or other error messages. This is just one of
many ways I have tried, but I haven't found one that works yet.

What I am looking for is actual to retrieve the sql string from
fields where there is a lookup with a combo box display control (so
that I can run code to change the sql)
Nov 19 '05 #1
7 8490
On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
<do*********@verizon.net> wrote:

The reason for the error is that:
DataType
is not a defined variable.
You might want to try the literal string:
"DataType"

I typically write:
for each prop in fld.Properties
debug.print prop.name, prop.value
next prop

-Tom.

Is it possible to retrieve field properties from a table in access2000
using code?

I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as dao.property

set dbs = CurrentDb
set tbl = dbs.TableDefs(tableName)
set fld = tbl.Fields(fieldName)
set prop = fld.Properties(DataType)

debug.print prop.name
"
and I get Type Mismatch, or other error messages. This is just one of
many ways I have tried, but I haven't found one that works yet.

What I am looking for is actual to retrieve the sql string from
fields where there is a lookup with a combo box display control (so
that I can run code to change the sql)


Nov 19 '05 #2
Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"


On Fri, 18 Nov 2005 21:28:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
<do*********@verizon.net> wrote:

The reason for the error is that:
DataType
is not a defined variable.
You might want to try the literal string:
"DataType"

I typically write:
for each prop in fld.Properties
debug.print prop.name, prop.value
next prop

-Tom.

Is it possible to retrieve field properties from a table in access2000
using code?

I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as dao.property

set dbs = CurrentDb
set tbl = dbs.TableDefs(tableName)
set fld = tbl.Fields(fieldName)
set prop = fld.Properties(DataType)

debug.print prop.name
"
and I get Type Mismatch, or other error messages. This is just one of
many ways I have tried, but I haven't found one that works yet.

What I am looking for is actual to retrieve the sql string from
fields where there is a lookup with a combo box display control (so
that I can run code to change the sql)


Nov 19 '05 #3
What's the DataType property?

Are you talking about the Type property? If so, you will not be able to
alter the property after the initial CreateField().

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Donald Grove" <do*********@verizon.net> wrote in message
news:el********************************@4ax.com...
Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"

Nov 19 '05 #4
On Sat, 19 Nov 2005 13:33:21 GMT, Donald Grove
<do*********@verizon.net> wrote:

I see another problem. Your code should be:
Dim prop As DAO.Property
Not the collection, but an individual one.

-Tom.
Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"


On Fri, 18 Nov 2005 21:28:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
<do*********@verizon.net> wrote:

The reason for the error is that:
DataType
is not a defined variable.
You might want to try the literal string:
"DataType"

I typically write:
for each prop in fld.Properties
debug.print prop.name, prop.value
next prop

-Tom.

Is it possible to retrieve field properties from a table in access2000
using code?

I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as dao.property

set dbs = CurrentDb
set tbl = dbs.TableDefs(tableName)
set fld = tbl.Fields(fieldName)
set prop = fld.Properties(DataType)

debug.print prop.name
"
and I get Type Mismatch, or other error messages. This is just one of
many ways I have tried, but I haven't found one that works yet.

What I am looking for is actual to retrieve the sql string from
fields where there is a lookup with a combo box display control (so
that I can run code to change the sql)


Nov 19 '05 #5
Yes, I finally figured that one out. Thanks to both Allen Browne and
Tom Van Stiphout for your help!

I now can generate documentation for all the fields in my tables. I
am very happy.

But now a new question: I want to do the same thing for forms. I have
created (borrowed) a system for identifying the forms in the AllForms
collection, opening them one by one, and listing all their controls.
But if the control is a combo box, I would like to be able to retrieve
its rowsource sql string and so far I am not having any luck

dim ctl as Control
strRowSource = ctl.Properties("rowsource")

does not return anything. Ideas?

(The idea is to identify combo box controls with SQL that matches
combo box lookup controls in table fields)
On Sat, 19 Nov 2005 10:57:53 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 13:33:21 GMT, Donald Grove
<do*********@verizon.net> wrote:

I see another problem. Your code should be:
Dim prop As DAO.Property
Not the collection, but an individual one.

-Tom.
Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"


On Fri, 18 Nov 2005 21:28:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
<do*********@verizon.net> wrote:

The reason for the error is that:
DataType
is not a defined variable.
You might want to try the literal string:
"DataType"

I typically write:
for each prop in fld.Properties
debug.print prop.name, prop.value
next prop

-Tom.
Is it possible to retrieve field properties from a table in access2000
using code?

I have tried:
"
dim dbs as dao.database
dim tbl as dao.tabledef
dim fld as dao.field
dim prop as dao.property

set dbs = CurrentDb
set tbl = dbs.TableDefs(tableName)
set fld = tbl.Fields(fieldName)
set prop = fld.Properties(DataType)

debug.print prop.name
"
and I get Type Mismatch, or other error messages. This is just one of
many ways I have tried, but I haven't found one that works yet.

What I am looking for is actual to retrieve the sql string from
fields where there is a lookup with a combo box display control (so
that I can run code to change the sql)


Nov 19 '05 #6
On Sat, 19 Nov 2005 22:57:18 GMT, Donald Grove
<do*********@verizon.net> wrote:

Not sure what the problem is. This works for me in the Northwind
sample application:
?forms("Employees").Controls("ReportsTo").Properti es("RowSource").Value

You do set your control object before trying to read a property,
right? Here is a more complete sample:
Sub ListForms()
Dim o As AccessObject
Dim f As Form
Dim ctl As Control
Dim prop As Property

On Error Resume Next 'Because can't get value of all
properties.
For Each o In Application.CurrentProject.AllForms
DoCmd.OpenForm o.Name, acDesign
Set f = Forms(o.Name)
For Each ctl In f.Controls
For Each prop In ctl.Properties
Debug.Print o.Name, ctl.Name, prop.Name, prop.Value
Next prop
Next ctl
DoCmd.Close acForm, o.Name
Set f = Nothing
Next o
End Sub

Yes, I finally figured that one out. Thanks to both Allen Browne and
Tom Van Stiphout for your help!

I now can generate documentation for all the fields in my tables. I
am very happy.

But now a new question: I want to do the same thing for forms. I have
created (borrowed) a system for identifying the forms in the AllForms
collection, opening them one by one, and listing all their controls.
But if the control is a combo box, I would like to be able to retrieve
its rowsource sql string and so far I am not having any luck

dim ctl as Control
strRowSource = ctl.Properties("rowsource")

does not return anything. Ideas?

(The idea is to identify combo box controls with SQL that matches
combo box lookup controls in table fields)
On Sat, 19 Nov 2005 10:57:53 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 13:33:21 GMT, Donald Grove
<do*********@verizon.net> wrote:

I see another problem. Your code should be:
Dim prop As DAO.Property
Not the collection, but an individual one.

-Tom.
Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"


On Fri, 18 Nov 2005 21:28:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:

On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
<do*********@verizon.net> wrote:

The reason for the error is that:
DataType
is not a defined variable.
You might want to try the literal string:
"DataType"

I typically write:
for each prop in fld.Properties
debug.print prop.name, prop.value
next prop

-Tom.
>Is it possible to retrieve field properties from a table in access2000
>using code?
>
>I have tried:
>"
>dim dbs as dao.database
>dim tbl as dao.tabledef
>dim fld as dao.field
>dim prop as dao.property
>
>set dbs = CurrentDb
>set tbl = dbs.TableDefs(tableName)
>set fld = tbl.Fields(fieldName)
>set prop = fld.Properties(DataType)
>
>debug.print prop.name
>"
>and I get Type Mismatch, or other error messages. This is just one of
>many ways I have tried, but I haven't found one that works yet.
>
> What I am looking for is actual to retrieve the sql string from
>fields where there is a lookup with a combo box display control (so
>that I can run code to change the sql)


Nov 20 '05 #7
It may take me a while to understand why my old code didn't work. But
yours works extremely well and I am very grateful to you! Thanks.
On Sat, 19 Nov 2005 17:00:05 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 22:57:18 GMT, Donald Grove
<do*********@verizon.net> wrote:

Not sure what the problem is. This works for me in the Northwind
sample application:
?forms("Employees").Controls("ReportsTo").Propert ies("RowSource").Value

You do set your control object before trying to read a property,
right? Here is a more complete sample:
Sub ListForms()
Dim o As AccessObject
Dim f As Form
Dim ctl As Control
Dim prop As Property

On Error Resume Next 'Because can't get value of all
properties.
For Each o In Application.CurrentProject.AllForms
DoCmd.OpenForm o.Name, acDesign
Set f = Forms(o.Name)
For Each ctl In f.Controls
For Each prop In ctl.Properties
Debug.Print o.Name, ctl.Name, prop.Name, prop.Value
Next prop
Next ctl
DoCmd.Close acForm, o.Name
Set f = Nothing
Next o
End Sub

Yes, I finally figured that one out. Thanks to both Allen Browne and
Tom Van Stiphout for your help!

I now can generate documentation for all the fields in my tables. I
am very happy.

But now a new question: I want to do the same thing for forms. I have
created (borrowed) a system for identifying the forms in the AllForms
collection, opening them one by one, and listing all their controls.
But if the control is a combo box, I would like to be able to retrieve
its rowsource sql string and so far I am not having any luck

dim ctl as Control
strRowSource = ctl.Properties("rowsource")

does not return anything. Ideas?

(The idea is to identify combo box controls with SQL that matches
combo box lookup controls in table fields)
On Sat, 19 Nov 2005 10:57:53 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On Sat, 19 Nov 2005 13:33:21 GMT, Donald Grove
<do*********@verizon.net> wrote:

I see another problem. Your code should be:
Dim prop As DAO.Property
Not the collection, but an individual one.

-Tom.

Sorry, but that isn't working, or I am not understanding you. I
suspect I am missing a step.

Here is my code, and I will include the opening declarations, in case
that is where my mistake is:
"
Dim dbs As DAO.Database
Dim fld As DAO.Field
Dim tbl As DAO.TableDef
Dim prop As DAO.Properties

Set dbs = CurrentDb
Set tbl = dbs.TableDefs(table)
Set fld = tbl.Fields(field)
Set prop = fld.Properties(property)

Debug.Print tbl.Name
Debug.Print fld.Name
debug.print prop.name
"

for this line:

Set prop = fld.Properties(0) --trying an integer where zero is just an
example OR

Set prop = fld.Properties("datatype") --trying a literal text string

I get a "type mismatch"

for this line:

Set prop = fld.Properties(dataype) --text string without quotes

I get "property not found"


On Fri, 18 Nov 2005 21:28:45 -0700, Tom van Stiphout
<no*************@cox.net> wrote:

>On Sat, 19 Nov 2005 03:31:32 GMT, Donald Grove
><do*********@verizon.net> wrote:
>
>The reason for the error is that:
>DataType
>is not a defined variable.
>You might want to try the literal string:
>"DataType"
>
>I typically write:
>for each prop in fld.Properties
> debug.print prop.name, prop.value
>next prop
>
>-Tom.
>
>
>>Is it possible to retrieve field properties from a table in access2000
>>using code?
>>
>>I have tried:
>>"
>>dim dbs as dao.database
>>dim tbl as dao.tabledef
>>dim fld as dao.field
>>dim prop as dao.property
>>
>>set dbs = CurrentDb
>>set tbl = dbs.TableDefs(tableName)
>>set fld = tbl.Fields(fieldName)
>>set prop = fld.Properties(DataType)
>>
>>debug.print prop.name
>>"
>>and I get Type Mismatch, or other error messages. This is just one of
>>many ways I have tried, but I haven't found one that works yet.
>>
>> What I am looking for is actual to retrieve the sql string from
>>fields where there is a lookup with a combo box display control (so
>>that I can run code to change the sql)


Nov 20 '05 #8

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

Similar topics

4
by: Dixie | last post by:
I wish to be able to do some things to tables in code. 1. Add a field and its properties. 2. Alter the properties of an existing field in a table. 3. Append some extra entries onto the bottom of...
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...
1
by: Adam | last post by:
It seems you cannot through an httpmodule alter request.headers. Is there a way around this (sure.. it works fine in isapi of course). It doesn't seem to have been changed in asp.net 2.0 either....
1
by: Jim | last post by:
Hi, I want to add a field to a table in a database that is live and being accessed from the web. I'm using phpMyAdmin and when I try to add the field I get error #1142...
2
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What...
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
17
by: The Frog | last post by:
Hello everyone, I am working on an application that can build database objects in MS Access from text files. I suppose you could call it a backup and restore type routine. Accessing the...
3
Corster
by: Corster | last post by:
I'm fairly new to Access, so please have patience... I have an application that I've written to audit all of our computers, monitors etc. which also works-out the Intel processor details from the...
4
by: shredder249 | last post by:
Hi, I have a form in MS Access 2003 where the user types a file extension into one text box (e.g. mp3), a folder path into another text box (e.g. D:\Backup) and a song name into a third text box...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.