<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBScript: Создать свойство Caption для поля  Access]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=8743</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8743&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBScript: Создать свойство Caption для поля  Access».]]></description>
		<lastBuildDate>Thu, 10 Oct 2013 03:59:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBScript: Создать свойство Caption для поля  Access]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=75910#p75910</link>
			<description><![CDATA[<p><strong>yuriy2000</strong>, полагаю потому, что второе относится к, собственно, самой базе данных, а первое — сугубо к Access.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 10 Oct 2013 03:59:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=75910#p75910</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBScript: Создать свойство Caption для поля  Access]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=75907#p75907</link>
			<description><![CDATA[<p>Нашел путем эксперимента в чем была проблема - оказывается свойство &quot;подпись&quot; (Caption) для поля можно добавить только после того как сама таблица уже создана. Т.е. сперва создали таблицу, а потом уже можно и свойства полей этой таблицы присваивать. Хотя &quot;стандартные&quot; свойства Size, Required и т.д.) можно присваивать в процессе создания. <br />На мой взгляд не логично <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (yuriy2000)]]></author>
			<pubDate>Thu, 10 Oct 2013 02:23:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=75907#p75907</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBScript: Создать свойство Caption для поля  Access]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=75862#p75862</link>
			<description><![CDATA[<p>Мне таки хотелось бы через VBScript - я же приложил <strong>свой</strong> пример, а что разве проблема именно в этом?</p>]]></description>
			<author><![CDATA[null@example.com (yuriy2000)]]></author>
			<pubDate>Wed, 09 Oct 2013 01:56:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=75862#p75862</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBScript: Создать свойство Caption для поля  Access]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=75855#p75855</link>
			<description><![CDATA[<p>Вам именно VBScript или таки VBA?</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Tue, 08 Oct 2013 19:58:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=75855#p75855</guid>
		</item>
		<item>
			<title><![CDATA[VBScript: Создать свойство Caption для поля  Access]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=75852#p75852</link>
			<description><![CDATA[<p>Добрый день/вечер!</p><p>Подскажите как программным путем создать Свойство &quot;подпись&quot; (Caption) для поля в базе&nbsp; Access.<br />Если это свойство было инициализировано, то его можно изменить, например так<br /></p><div class="codebox"><pre><code>
Set oEngine = CreateObject(&quot;DAO.DBEngine.120&quot;)
Set oDB = oEngine.OpenDatabase(&quot;Test1.accdb&quot;)

oDB.TableDefs(&quot;Table1&quot;).Fields(0).Properties(&quot;Caption&quot;) = &quot;Test1&quot;
</code></pre></div><p>Если поле не было инициализировано ранее, то выдается ошибка. А вот как инициализировать при создании БД программным путем?</p><p>Нашел <a href="http://www.allenbrowne.com/func-DAO.html">здесь</a> примеры по работе с Property через DAO, но что-то не помогло. Т.е. не создается Caption.</p><div class="codebox"><pre><code>Function SetPropertyDAO(obj As Object, strPropertyName As String, intType As Integer, _
    varValue As Variant, Optional strErrMsg As String) As Boolean
On Error GoTo ErrHandler
    &#039;Purpose:   Set a property for an object, creating if necessary.
    &#039;Arguments: obj = the object whose property should be set.
    &#039;           strPropertyName = the name of the property to set.
    &#039;           intType = the type of property (needed for creating)
    &#039;           varValue = the value to set this property to.
    &#039;           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 &amp; obj.Name &amp; &quot;.&quot; &amp; strPropertyName &amp; &quot; not set to &quot; &amp; varValue &amp; _
        &quot;. Error &quot; &amp; Err.Number &amp; &quot; - &quot; &amp; Err.Description &amp; vbCrLf
    Resume ExitHandler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
    &#039;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
</code></pre></div><p>Высылаю свой пример скрипта.</p>]]></description>
			<author><![CDATA[null@example.com (yuriy2000)]]></author>
			<pubDate>Tue, 08 Oct 2013 18:40:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=75852#p75852</guid>
		</item>
	</channel>
</rss>
