+ Reply to Thread
Results 1 to 2 of 2

Error Message object required

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    13

    Error Message object required

    Hi
    I am getting an error message object required. i just cant see what is wrong. i am trying to retrieve information from database.

    Dim rsdata As ADODB.Recordset
    Dim sConnected As String
    Dim sSQL As String

    sConnected = "Provider=Microsoft.ACE.OLEDB.12.0;" & " Data Source=C:\Users\c0861205\Documents\Docs\Access_VBA\Adding.accdb;"
    sSQL = "Select From_Date,[To_Date]+''+[NT]+''+Provincial from tblAdding"
    Set rsdata = New ADODB.Recordset
    rsdata.Open sSQL, sConnected, adOpenForwardOnly, adLockReadOnly, adCmdText

    If Not rsdata.EOF Then
    Inform.Range("A2").CopyFromRecordset rsdata
    rsdata.Close
    With Inform.Range("A1:B1")
    .Value = Array("From_Date", "To_Date", "NT", "Provincial")
    .Font.Bold = True
    End With
    Inform.UsedRange.EntireColumn.AutoFit
    Else
    rsdata.Close
    MsgBox "Error: No records retured.", vbCritical
    End If
    Set rsdata = Nothing

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,040

    Re: Error Message object required

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Never use Merged Cells in Excel

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1