在代码中设置字段属性 [英] Setting field properties in code

查看:114
本文介绍了在代码中设置字段属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在代码中的日期/时间字段中设置Format属性吗?

我可以在代码中的日期/时间字段中设置输入掩码吗?


我可以在代码中将是/否字段的格式设置为复选框吗?


我正在进行表格和字段的远程更新,并且可以''找到足够的

这些东西的信息。


另外,你如何索引代码中的字段?


TIA

dixie

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 a remote update of tables and fields and can''t find enough
information on these things.

Also, how do you index a field in code?

TIA
dixie

推荐答案

如果TableDef中的Field没有该属性,则需要

CreateProperty()。下面的示例显示了如果创建属性

不存在,并设置它。


将是/否字段显示为s检查框,创建并设置

DisplayControl属性。


要在字段上创建索引,请在桌面上创建CreateIndex。


请注意,如果您正在使用附表,则需要

OpenDatabase并直接在后端工作。


示例下面说明了如何设置您可能认为标准的内容

属性:

- 将表的'SubDatasheetName设置为[无]。

- 将AllowZeroLength设置为No表示所有文本字段,备忘录和超链接。

- 删除该数字作为数字字段的默认值。

- 设置Currency类型的Format属性(如果你愿意,可以说明如何设置默认值。)

- 设置是/否字段显示为复选框。

- 设置Capti在具有混合大小写名称的字段上使用空格(例如

OrderDate。)

- 设置每个字段的描述


最后,最后一个示例显示了如何创建主键索引,

单字段索引和多字段索引。


粘贴把代码放到模块中,看看它是如何工作的。

----------------------代码启动------ -----------

Sub StandardProperties(strTableName As String)

''目的:默认情况下你想要设置的属性:

''TableDef:Subdatasheets off。

''数字字段:删除默认值。

''货币字段:格式为货币。

''是/否字段:显示为复选框。默认为否。

''文本/备忘录/超链接:AllowZeroLength关闭,

''UnicodeCompression on。

''所有字段:添加如果是混合的情况下的标题。

''参数:表的名称。

''注意:需要:SetPropertyDAO()

Dim db作为DAO.Database''当前数据库。

Dim tdf作为DAO.TableDef''表在参数中提名。

Dim fld作为DAO.Field''每个字段。

Dim strCaption As String''字段标题。

Dim strErrMsg As String''响应和错误消息。


''Initalize 。

设置db = CurrentDb()

设置tdf = db.TableDefs(strTableName)


''设置表' 's SubdatasheetName。

调用SetPropertyDAO(tdf,SubdatasheetName",dbText," [None]",_

strErrMsg)

>
每个fld在tdf.Fiel中ds

''处理不同字段类型的默认值。

选择Case fld.Type

Case dbText,dbMemo''包括超链接。

fld.AllowZeroLength = False

调用SetPropertyDAO(fld,UnicodeCompression",dbBoolean,_

True,strErrMsg)

案例dbCurrency

fld.DefaultValue = 0

调用SetPropertyDAO(fld,格式,dbText,货币,_

strErrMsg)

案例dbLong,dbInteger,dbByte,dbDouble,dbSingle,dbDecimal

fld.DefaultValue = vbNullString

案例dbBoolean

调用SetPropertyDAO(fld,DisplayControl,dbInteger,_

CInt(acCheckBox))

结束选择


''如果需要设置标题。

strCaption = ConvertMixedCase(fld.Name)

如果strCaption<> fld.Name然后

调用SetPropertyDAO(fld,Caption,dbText,strCaption)

结束如果

下一页


''清理。

设置fld = Nothing

设置tdf = Nothing

设置db = Nothing

如果Len(strErrMsg)> 0然后

Debug.Print strErrMsg

Else

Debug.Print"为表格设置的属性 &安培; strTableName

结束如果

结束子


函数SetPropertyDAO(obj As Object,strPropertyName As String,_

intType As Integer,varValue As Variant,optional strErrMsg As String)As

Boolean

On Error GoTo ErrHandler

''目的:设置对象的属性,必要时创建。

''参数:obj =应设置其属性的对象。

''strPropertyName =属性的名称设置。

''intType =属性的类型(创建时需要)

''varValue =设置此属性的值。

''srrrrMsg =要附加任何错误消息的字符串。


如果HasProperty(obj,strPropertyName)那么

obj.Properties(strPropertyName)= varValue

Else

obj.Properties.Append obj.CreateProperty(strPropertyName,intType,

varValue)

结束If

SetPropertyDAO = True


ExitHandler:

退出功能


ErrHandler:

strErrMsg = strErrMsg& obj.Name& "。" &安培; strPropertyName& "没有设定为

" &安培; varValue& " ;.错误 &安培; Err.Number& " - &安培; Err.Description& vbCrLf

恢复ExitHandler

结束函数

公共函数HasProperty(obj As Object,strPropName As String)As Boolean

''目的:如果对象具有属性,则返回true。

Dim varDummy As Variant


On Error Resume Next

varDummy = obj.Properties(strPropName)

HasProperty =(Err.Number = 0)

结束功能


Sub CreateIndexesDAO()

Dim db作为DAO.Database

Dim tdf作为DAO.TableDef

Dim ind作为DAO.Index


''初始化

设置db = CurrentDb()

设置tdf = db.TableDefs(" tblDaoContractor")


''1。主键索引。

设置ind = tdf.CreateIndex(" PrimaryKey")

使用ind

.Fields.Append .CreateField(" ; ContractorID")

.Unique = False

.Primary = True

结束

tdf.Indexes。追加ind


''2。单字段索引。

设置ind = tdf.CreateIndex(" Inactive")

ind.Fields.Append ind.CreateField(" Inactive")

tdf.Indexes.Append ind


''3。多字段索引。

设置ind = tdf.CreateIndex(" FullName")

使用ind

.Fields.Append .CreateField( Surname)

.Fields.Append .CreateField(" FirstName")

结束

tdf.Indexes.Append ind


''刷新此系列的显示。

tdf.Indexes.Refresh


''清理

设置ind = Nothing

设置tdf = Nothing

设置db = Nothing

Debug.Print" tblDaoContractor indices创建。

结束子

----------------------代码结束---- -------------


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Dixie" <二*** @ dogmail.com>在消息中写道

news:43 ******** @ duster.adelaide.on.net ...
If the Field in the TableDef does not have the property, you need to
CreateProperty(). The example below shows how to create the property if it
does not exist, and set it.

To make a yes/no field display as s check box, create and set the
DisplayControl property.

To create an index on a field, CreateIndex on the table.

Note that if you are working on an attached table, you will need to
OpenDatabase and work directly on the back end.

The example below illustrates how to set what you might consider standard
properties:
- setting the table''s SubDatasheetName to [None].
- setting AllowZeroLength to No for all text fields, memos, and hyperlinks.
- removing that darn zero as Default Value for numeric fields.
- setting the Format property for Currency types (and illustrating how to
set the Default Value if you wish.)
- setting Yes/No fields to display as a check box.
- setting a Caption with spaces on fields that have a mixed-case name (e.g.
OrderDate.)
- setting a Description of each field

Finally, the last example shows how to create a primary key index, a
single-field index, and a multi-field index.

Paste the code into a module, and see how it works.
----------------------code starts-----------------
Sub StandardProperties(strTableName As String)
''Purpose: Properties you always want set by default:
'' TableDef: Subdatasheets off.
'' Numeric fields: Remove Default Value.
'' Currency fields: Format as currency.
'' Yes/No fields: Display as check box. Default to No.
'' Text/memo/hyperlink: AllowZeroLength off,
'' UnicodeCompression on.
'' All fields: Add a caption if mixed case.
''Argument: Name of the table.
''Note: Requires: SetPropertyDAO()
Dim db As DAO.Database ''Current database.
Dim tdf As DAO.TableDef ''Table nominated in argument.
Dim fld As DAO.Field ''Each field.
Dim strCaption As String ''Field caption.
Dim strErrMsg As String ''Responses and error messages.

''Initalize.
Set db = CurrentDb()
Set tdf = db.TableDefs(strTableName)

''Set the table''s SubdatasheetName.
Call SetPropertyDAO(tdf, "SubdatasheetName", dbText, "[None]", _
strErrMsg)

For Each fld In tdf.Fields
''Handle the defaults for the different field types.
Select Case fld.Type
Case dbText, dbMemo ''Includes hyperlinks.
fld.AllowZeroLength = False
Call SetPropertyDAO(fld, "UnicodeCompression", dbBoolean, _
True, strErrMsg)
Case dbCurrency
fld.DefaultValue = 0
Call SetPropertyDAO(fld, "Format", dbText, "Currency", _
strErrMsg)
Case dbLong, dbInteger, dbByte, dbDouble, dbSingle, dbDecimal
fld.DefaultValue = vbNullString
Case dbBoolean
Call SetPropertyDAO(fld, "DisplayControl", dbInteger, _
CInt(acCheckBox))
End Select

''Set a caption if needed.
strCaption = ConvertMixedCase(fld.Name)
If strCaption <> fld.Name Then
Call SetPropertyDAO(fld, "Caption", dbText, strCaption)
End If
Next

''Clean up.
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
If Len(strErrMsg) > 0 Then
Debug.Print strErrMsg
Else
Debug.Print "Properties set for table " & strTableName
End If
End Sub

Function SetPropertyDAO(obj As Object, strPropertyName As String, _
intType As Integer, varValue As Variant, Optional strErrMsg As String) As
Boolean
On Error GoTo ErrHandler
''Purpose: Set a property for an object, creating if necessary.
''Arguments: obj = the object whose property should be set.
'' strPropertyName = the name of the property to set.
'' intType = the type of property (needed for creating)
'' varValue = the value to set this property to.
'' strErrMsg = string to append any error message to.

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName, intType,
varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & " not set to
" & varValue & ". Error " & Err.Number & " - " & Err.Description & vbCrLf
Resume ExitHandler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
''Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

Sub CreateIndexesDAO()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index

''Initialize
Set db = CurrentDb()
Set tdf = db.TableDefs("tblDaoContractor")

''1. Primary key index.
Set ind = tdf.CreateIndex("PrimaryKey")
With ind
.Fields.Append .CreateField("ContractorID")
.Unique = False
.Primary = True
End With
tdf.Indexes.Append ind

''2. Single-field index.
Set ind = tdf.CreateIndex("Inactive")
ind.Fields.Append ind.CreateField("Inactive")
tdf.Indexes.Append ind

''3. Multi-field index.
Set ind = tdf.CreateIndex("FullName")
With ind
.Fields.Append .CreateField("Surname")
.Fields.Append .CreateField("FirstName")
End With
tdf.Indexes.Append ind

''Refresh the display of this collection.
tdf.Indexes.Refresh

''Clean up
Set ind = Nothing
Set tdf = Nothing
Set db = Nothing
Debug.Print "tblDaoContractor indexes created."
End Sub
----------------------code ends-----------------

--
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.

"Dixie" <di***@dogmail.com> wrote in message
news:43********@duster.adelaide.on.net...
我可以在日期中设置Format属性吗?代码中的/ time字段?

我可以在代码中的日期/时间字段中设置输入掩码吗?

我可以将是/否字段的格式设置为Checkbox在代码中?

我正在进行表格和字段的远程更新,但是找不到关于这些东西的足够信息。

另外,怎么做你在代码中索引一个字段?

TIA
dixie
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 a remote update of tables and fields and can''t find enough
information on these things.

Also, how do you index a field in code?

TIA
dixie



好的,我已经将代码复制到一个模块,玩了一下。


现在只想说我想为日期/时间创建一个d / m / yyyy的格式属性

名为StartDate的字段,在名为Faculty的表中,我将要执行此操作所需的

语法是什么。我知道这就是我需要做的事情,但不能解决这些争论以及它们是如何结合在一起的。


dixie


" Allen Browne" <铝********* @ SeeSig.Invalid>在消息中写道

news:43 *********************** @ per-qv1-newsreader-01.iinet.net。 au ...
OK, I''ve copied the code into a module and had a play with it.

Now just say I want to create a format property of d/m/yyyy for a date/time
field called StartDate, that is in a table called Faculty, what is the
syntax I need for the event I am going to do this from. I know that is what
I have to do, but can''t work out the arguments and how they come together.

dixie

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
如果TableDef中的Field没有该属性,则需要
CreateProperty()。下面的示例显示了如果
不存在而创建属性,并设置它。

要将是/否字段显示为s复选框,请创建并设置
DisplayControl属性。

要在字段上创建索引,在表上创建CreateIndex。

请注意,如果您正在处理附加表,则需要
OpenDatabase并直接在后端工作。

下面的例子说明了如何设置你可能认为标准的属性:
- 设置表的'SubDatasheetName到[无]。
- 为所有文本字段,备忘录和
超链接设置AllowZeroLength为否。
- 删除数字字段的默认值为零。
- 设置货币类型的格式属性(并说明如何根据需要设置默认值。)
- 设置是/否字段显示为复选框。
- 设置标题为具有混合大小写名称的字段上的空格
(例如OrderDat e。)
- 设置每个字段的描述

最后,最后一个示例显示了如何创建主键索引,
单字段索引和多个字段索引。

将代码粘贴到模块中,看看它是如何工作的。
----------------------代码启动-----------------
Sub StandardProperties(strTableName As String)
''目的:默认情况下你想要设置的属性:
''TableDef:Subdatasheets off。
''数字字段:删除默认值。
''货币字段:格式为货币。
''是/否字段:显示为复选框。默认为否。
''文本/备忘录/超链接:允许零点关闭,
''UnicodeCompression on。
''所有字段:如果是混合大小写,请添加标题。
''参数:表的名称。
''注意:需要:SetPropertyDAO()
Dim db作为DAO.Database''当前数据库。
Dim tdf As DAO.TableDef''Table in cominated in Dim fld作为DAO.Field''每个字段。
Dim strCaption As String''字段标题。
Dim strErrMsg As String''响应和错误消息。

''初始化。
设置db = CurrentDb()
设置tdf = db.TableDefs(strTableName)

''设置表的'SubdatasheetName。
调用SetPropertyDAO(tdf,SubdatasheetName,dbText,[无],
strErrMsg

对于每个fld在tdf.Fields中
''处理不同字段类型的默认值。
选择Case fld.Type
Case dbText,dbMemo''包括超链接。
fld.AllowZeroLength = False
调用SetPropertyDAO(fld,UnicodeCompression ;,dbBoolean,_
True,strErrMsg)
Case dbCurrency
fld.DefaultValue = 0
调用SetPropertyDAO(fld,Format,dbText," Currency",_
strErrMsg)
案例dbLong,dbInteger,dbByte,dbDouble,dbSingle,dbDecimal
fld.DefaultValue = vbNullString
案例dbBoolean
调用SetPropertyDAO(fld," DisplayControl" ,dbInteger,_
CInt(acCheckBox))
结束选择

''如果需要设置标题。
strCaption = ConvertMixedCase(fld.Name)
如果strCaption<> fld.Name然后
调用SetPropertyDAO(fld,Caption,dbText,strCaption)
结束如果

''清理。
设置fld = Nothing
设置tdf = Nothing
设置db = Nothing
如果Len(strErrMsg)> 0然后
Debug.Print strErrMsg
另外
Debug.Print为表格设置的属性 &安培; strTableName
结束如果


函数SetPropertyDAO(obj As Object,strPropertyName As String,_
intType As Integer,varValue As Variant,optional strErrMsg As String) As
Boolean
On Error GoTo ErrHandler
''目的:设置对象的属性,必要时创建。
''参数:obj =应设置其属性的对象。
''strPropertyName =要设置的属性的名称。
''intType =属性的类型(创建时需要)
''varValue =设置此属性的值。
''strErrMsg =要附加任何错误信息的字符串。

如果HasProperty(obj,strPropertyName)那么
obj.Properties(strPropertyName)= varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName,intType,
varValue)
结束如果
SetPropertyDAO = True

ExitHandler:<退出功能

ErrHandler:
strErrMsg = strErrMsg& obj.Name& "。" &安培; strPropertyName& "没有设置为
&安培; varValue& " ;.错误 &安培; Err.Number& " - &安培; Err.Description& vbCrLf
恢复ExitHandler
结束函数

公共函数HasProperty(obj As Object,strPropName As String)As
Boolean
''目的:如果返回true该对象具有该属性。
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty =(Err.Number = 0 )
结束函数

Sub CreateIndexesDAO()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index

''初始化
设置db = CurrentDb()
设置tdf = db.TableDefs(" tblDaoContractor")

''1。主键索引。
设置ind = tdf.CreateIndex(" PrimaryKey")
使用ind
.Fields.Append .CreateField(" ContractorID")
.Unique = False
.Primary = True
结束
tdf.Indexes.Append ind

''2。单场索引。
设置ind = tdf.CreateIndex(" Inactive")
ind.Fields.Append ind.CreateField(" Inactive")
tdf.Indexes.Append ind

''3。多字段索引。
设置ind = tdf.CreateIndex(" FullName")
使用ind
.Fields.Append .CreateField(" Surname")
.Fields。追加.CreateField(" FirstName")
结束
tdf.Indexes.Append ind

''刷新此系列的显示。
tdf.Indexes。刷新

''清理
设置ind = Nothing
设置tdf = Nothing
设置db = Nothing
Debug.Print" tblDaoContractor索引创建。
End Sub
----------------------代码结束-------------- ---

-
Allen Browne - 微软MVP。西澳大利亚州珀斯。
访问用户提示 - http://allenbrowne.com/ tips.html
回复群组,而不是mvps dot org的allenbrowne。

Dixie <二*** @ dogmail.com>在消息中写道
新闻:43 ******** @ duster.adelaide.on.net ...
If the Field in the TableDef does not have the property, you need to
CreateProperty(). The example below shows how to create the property if it
does not exist, and set it.

To make a yes/no field display as s check box, create and set the
DisplayControl property.

To create an index on a field, CreateIndex on the table.

Note that if you are working on an attached table, you will need to
OpenDatabase and work directly on the back end.

The example below illustrates how to set what you might consider standard
properties:
- setting the table''s SubDatasheetName to [None].
- setting AllowZeroLength to No for all text fields, memos, and
hyperlinks.
- removing that darn zero as Default Value for numeric fields.
- setting the Format property for Currency types (and illustrating how to
set the Default Value if you wish.)
- setting Yes/No fields to display as a check box.
- setting a Caption with spaces on fields that have a mixed-case name
(e.g. OrderDate.)
- setting a Description of each field

Finally, the last example shows how to create a primary key index, a
single-field index, and a multi-field index.

Paste the code into a module, and see how it works.
----------------------code starts-----------------
Sub StandardProperties(strTableName As String)
''Purpose: Properties you always want set by default:
'' TableDef: Subdatasheets off.
'' Numeric fields: Remove Default Value.
'' Currency fields: Format as currency.
'' Yes/No fields: Display as check box. Default to No.
'' Text/memo/hyperlink: AllowZeroLength off,
'' UnicodeCompression on.
'' All fields: Add a caption if mixed case.
''Argument: Name of the table.
''Note: Requires: SetPropertyDAO()
Dim db As DAO.Database ''Current database.
Dim tdf As DAO.TableDef ''Table nominated in argument.
Dim fld As DAO.Field ''Each field.
Dim strCaption As String ''Field caption.
Dim strErrMsg As String ''Responses and error messages.

''Initalize.
Set db = CurrentDb()
Set tdf = db.TableDefs(strTableName)

''Set the table''s SubdatasheetName.
Call SetPropertyDAO(tdf, "SubdatasheetName", dbText, "[None]", _
strErrMsg)

For Each fld In tdf.Fields
''Handle the defaults for the different field types.
Select Case fld.Type
Case dbText, dbMemo ''Includes hyperlinks.
fld.AllowZeroLength = False
Call SetPropertyDAO(fld, "UnicodeCompression", dbBoolean, _
True, strErrMsg)
Case dbCurrency
fld.DefaultValue = 0
Call SetPropertyDAO(fld, "Format", dbText, "Currency", _
strErrMsg)
Case dbLong, dbInteger, dbByte, dbDouble, dbSingle, dbDecimal
fld.DefaultValue = vbNullString
Case dbBoolean
Call SetPropertyDAO(fld, "DisplayControl", dbInteger, _
CInt(acCheckBox))
End Select

''Set a caption if needed.
strCaption = ConvertMixedCase(fld.Name)
If strCaption <> fld.Name Then
Call SetPropertyDAO(fld, "Caption", dbText, strCaption)
End If
Next

''Clean up.
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
If Len(strErrMsg) > 0 Then
Debug.Print strErrMsg
Else
Debug.Print "Properties set for table " & strTableName
End If
End Sub

Function SetPropertyDAO(obj As Object, strPropertyName As String, _
intType As Integer, varValue As Variant, Optional strErrMsg As String) As
Boolean
On Error GoTo ErrHandler
''Purpose: Set a property for an object, creating if necessary.
''Arguments: obj = the object whose property should be set.
'' strPropertyName = the name of the property to set.
'' intType = the type of property (needed for creating)
'' varValue = the value to set this property to.
'' strErrMsg = string to append any error message to.

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName, intType,
varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & " not set to
" & varValue & ". Error " & Err.Number & " - " & Err.Description & vbCrLf
Resume ExitHandler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
''Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

Sub CreateIndexesDAO()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index

''Initialize
Set db = CurrentDb()
Set tdf = db.TableDefs("tblDaoContractor")

''1. Primary key index.
Set ind = tdf.CreateIndex("PrimaryKey")
With ind
.Fields.Append .CreateField("ContractorID")
.Unique = False
.Primary = True
End With
tdf.Indexes.Append ind

''2. Single-field index.
Set ind = tdf.CreateIndex("Inactive")
ind.Fields.Append ind.CreateField("Inactive")
tdf.Indexes.Append ind

''3. Multi-field index.
Set ind = tdf.CreateIndex("FullName")
With ind
.Fields.Append .CreateField("Surname")
.Fields.Append .CreateField("FirstName")
End With
tdf.Indexes.Append ind

''Refresh the display of this collection.
tdf.Indexes.Refresh

''Clean up
Set ind = Nothing
Set tdf = Nothing
Set db = Nothing
Debug.Print "tblDaoContractor indexes created."
End Sub
----------------------code ends-----------------

--
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.

"Dixie" <di***@dogmail.com> wrote in message
news:43********@duster.adelaide.on.net...
我可以在日期/时间字段中设置Format属性代码?

我可以在代码中的日期/时间字段中设置输入掩码吗?

我可以在代码中将是/否字段的格式设置为复选框吗? br />
我正在进行表格和字段的远程更新,但是找不到关于这些东西的足够信息。

另外,你如何索引字段在代码中?

TIA
dixie
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 a remote update of tables and fields and can''t find
enough information on these things.

Also, how do you index a field in code?

TIA
dixie




你已经在这里得到了一些答案。


我应该指出,修改表格中的格式不会改变现有应用程序中的

格式。


因此,表格设计模式中的格式只是默认值。并且,

因为一个优秀的开发人员永远不会允许用户直接查看,编辑或使用

表,那么你真的不必担心这个问题。只需

确保在设计和构建新表单时,为表单上的控件设置格式




所以,我不确定更改表格中的格式是否是您想要的,并且更糟糕的是,更改后,报表和表单上的控件将不会是
会在您执行此操作时更改。 (你在表格上放置的新控件,或报告

将使用这种新格式作为默认格式,但不存在)。


那么,关于如何你更新用户软件?好吧,解决方案是分割你的数据库,然后你可以安全地更新用户代码,表单等,并且

不必担心覆盖数据部分。你可以在这里阅读

如何运作:

http://www.members.shaw.ca/AlbertKal...plit/index.htm


-

Albert D. Kallal(访问MVP)

加拿大艾伯塔省埃德蒙顿
pl ***************** @ msn.com
http://www.members.shaw.ca/AlbertKallal
You got some answer here already.

I should point out that modifying the format in a table does NOT change the
format in your existing application.

So, that format in the table design mode is just there for a default. And,
since a good developer will NEVER allow users to see, or edit, or use the
tables direct, then you really don''t have to worry about this problem. Just
make sure that while you design and build new forms, that you set the format
for the control on the form.

So, I not sure if changing the format in a table is what you want, and
worse, after you change it, the controls on reports, and forms will NOT
change when you do this. (new controls you place on the forms, or reports
will use this new format as a default, but not existing).

So, as to how you update users software? Well, the solution is to split
your database, and then you can safely update the users code, forms etc, and
NOT have to worry about overwriting the data part. You can read about how
this works here:

http://www.members.shaw.ca/AlbertKal...plit/index.htm

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal


这篇关于在代码中设置字段属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆