Run-time error 3265

ImInfinite

New member
Local time
Today, 15:21
Joined
Sep 9, 2013
Messages
4
Hello everyone,

first of all, I do realize there is already a thread with a similar title, however its 2 years old and my problem seems to be different.

Here is whats wrong:
I copied code from Allen Browne (unfortunately I am not allowed to post links just yet :( ) he is quiet the man. His code lets me add checkboxes to my first column in a table that I previously created as a copy from my query. During this process all the checkboxes from my query where converted to 0 and -1. Thats why I needed Allen's code.

Now I wanted the table's name to be "MatchingTemp and the current Date and Time, so I did this:

Code:
Dim strDate As String
    Dim strTime As String
    strDate = Format(Date, "yyyy-mm-dd")
    strTime = Format(Time, "hh-mm")
    strSQL_Table = "SELECT Matched_Query.* INTO [MatchingTemp" & strDate & "-" & strTime & "] FROM Matched_Query" 
    DoCmd.RunSQL strSQL_Table

It works well and I have no Problem there. However, when trying to use the new name
Code:
"MatchingTemp" & strDate & "-" & strTime
for Allen's code, I get the error. Before my enhancement with the name it worked fine.
Here is the part that gives my an error.

Code:
Dim fld As DAO.Field
    Dim strName As String
    strName = "MatchingTemp" & strDate & "-" & strTime
    MsgBox strName
    Set fld = DBEngine(0)(0).TableDefs(strName).Fields("Field1")
    Call SetPropertyDAO(fld, "DisplayControl", dbInteger, CInt(acCheckBox))

I am an absolute noob in programming and VBA in particular. Any help would be greatly appreciated.

Thank you in advance!!!

Ps; here are the Allen's funtions
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
    '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
 
Last edited:
Hi JHB,

thank you very much for your response. However this was not the problem and I tried it before aswell ;)

I fixed it, with a bit of alternate code. Not sure what was the problem though. All I know is, it works now.

Code:
    strName = "MatchingTemp" & strDate & "-" & strTime
    Set db = CurrentDb
    Set fldMatching = db.TableDefs(strName).Fields("Field1")                                                                        'In Field1 in table strName
    Call SetPropertyDAO(fldMatching, "DisplayControl", dbInteger, CInt(acCheckBox))                                                 'instert checked Checkbox
 

Users who are viewing this thread

Back
Top Bottom