Results 1 to 5 of 5

Thread: VBA Recordset.Open Error

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    2

    Exclamation VBA Recordset.Open Error

    I'm getting a run-time error '-2147217833(80040e57)' String or binary data would be truncated.

    Code:
                objMyCmd.CommandText = strSQL
                objMyCmd.CommandType = adCmdText
                Set objMyRecordset.Source = objMyCmd
                If Err.Number = 0 Then
                    objMyRecordset.Open
                    If Not (objMyRecordset Is Nothing) Then
                        If (objMyRecordset.State And adStateOpen) = adStateOpen Then
                            objMyRecordset.Close
                            Set objMyRecordset = Nothing
                        End If
                    End If
                End If
    The connection is good but it looks but the error is happening at the "objMRecordset.Open" line.

    Any ideas what's going on here? It was working fine until I tried to add a SQL call to a second form in the same application. Prior to this modification it worked just fine.

    I removed the SQL Call from the second form and its still getting this error. I'm stumped so any help is GREATLY appreciated as I am currently STUCK!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,663

    Re: VBA Recordset.Open Error

    Office questions have their own forum.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,621

    Re: VBA Recordset.Open Error

    what type of database access are you using? ADO? DAO?

    post more of the project, including all variable dimensioning
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,908

    Re: VBA Recordset.Open Error

    '-2147217833(80040e57)' String or binary data would be truncated.
    The only time I've ever seen that error is during an update or insert when the data I'm trying to set is longer than the field allows. Specifically strings. For example, if the field is only 10 characters and I try to insert/update it to something that is 15 characters long, that error will occur.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    2

    Re: VBA Recordset.Open Error

    techgnome- That was the correct resolution. Thank you for your help...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width