Advertisement

07.01.2008 at 03:16PM PDT, ID: 23531913 | Points: 500
[x]
Attachment Details

Set Type property through VBA

Asked by Forensicon in Access Coding/Macros, Microsoft Access Database

Tags: microsoft, access, 2003

I can't figure out how to set the Type property for a column through vba. I already have a SetFieldProperty function written which i use to set the Description property for the tables but i can't figure out the syntax to set the Type property for a column to be a long date. Attached is the code i use to set the Description property for my tables. and what i've tried to write to set the Type property. Also, attached is the code for my SetFieldProperty.

Thanks for the helpStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
SetFieldProperty CurrentDb.TableDefs![USB_Friendly Names in USBSTOR], "Description", dbText, "6a. USBSTOR Friendly Names"
 
 
----------------------------
 
SetFieldProperty CurrentDb("[USB_Friendly Names in USBSTOR]")("Latest Reference Date"), "Type", dbDate, 8
 
 
---------------------------------------
 
Public Function SetFieldProperty(obj As Object, strName As String, varFieldType As Variant, varSetting As Variant) As Boolean
    Const conPropNotFound As Integer = 3270
    Dim prp As DAO.Property
    On Error GoTo SetFieldProperty_Error
    obj.Properties(strName) = varSetting
    obj.Properties.Refresh
    SetFieldProperty = True
   
SetFieldProperty_Exit:
    Exit Function
 
SetFieldProperty_Error:
    If Err = conPropNotFound Then
        Set prp = obj.CreateProperty(strName, varFieldType, varSetting)
        obj.Properties.Append prp
        obj.Properties.Refresh
        SetFieldProperty = True
        Resume SetFieldProperty_Exit
    Else
        MsgBox Err & ": " & vbCrLf & Err.Description, , CurrentProject.Name & ": Field Property Error"
        SetFieldProperty = False
        Resume SetFieldProperty_Exit
    End If
End Function
[+][-]07.02.2008 at 01:10AM PDT, ID: 21914322

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 07:11AM PDT, ID: 21916539

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 07:12AM PDT, ID: 21916550

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 07:24AM PDT, ID: 21916701

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208