+ Reply to Thread
Results 1 to 7 of 7

SQL Select statement not populating cells properly.

  1. #1
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    SQL Select statement not populating cells properly.

    I have an SQL SELECT statement that connects to the database fine but it will only populate the top cell for my last field.

    eg. SELECT ID, Date, Number, Pickup FROM tbl_test WHERE Pickup='condition 1'

    If there are 100 hundred records returned into the sheet columns A= all of the ID B=all of Date C=all Number but D only has one record at the top (d1). There is data in the database for the matching records but why will it only show up in one cell. It is a memo field in the database but that shouldn't matter if it displays one record. I hope I explained this enough and thanks for any help.

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: SQL Select statement not populating cells properly.

    Try first without WHERE clause and see if you get more records. If you do get more records then the problem could be trailing zeros.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: SQL Select statement not populating cells properly.

    how are you outputting the data?

    are you using Range.CopyfromRecordset?

  4. #4
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    Re: SQL Select statement not populating cells properly.

    Removed the WHERE clause and did get more records and now I have 3 cells that contain the data from the memo field. I know there is data in the database in that memo field but no idea why it won't populate the cell.
    Thanks

  5. #5
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    Re: SQL Select statement not populating cells properly.

    Yes I am using Range.CopyFromRecordset.

  6. #6
    Forum Contributor
    Join Date
    03-03-2011
    Location
    Ottawa, Ontario
    MS-Off Ver
    365
    Posts
    136

    Re: SQL Select statement not populating cells properly.

    I have deleted everything from my SELECT statement except for 'Pickup' which was the only memo field in the statement and still only get one record returned. All the other fields are text or numbers and they are returned for all the records. The only difference I can find is the memo field but not sure how I can work around this.

  7. #7
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: SQL Select statement not populating cells properly.

    Try cycling through the recordset and assigning the field to a String variable before outputting the data to the spreadsheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help with If Statement populating several Cells
    By JPWRana in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-27-2013, 12:55 AM
  2. Data from one sheet isnt populating properly if certain valuse are removed
    By menor59 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2013, 09:33 PM
  3. Populating Cells on Drop Down Select - Not sure what function to use
    By vricci in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-29-2013, 10:06 PM
  4. If Statement to avoid populating filled cells
    By carbonboywonder in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-05-2009, 08:57 AM
  5. [SOLVED] Populating a select group of cells with randomized names...
    By Kevin Lyons in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2005, 10:06 AM

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