Query result - some fields missing

Larry Haydn

Board Regular
Joined
Jul 18, 2019
Messages
207
Office Version
  1. 365
Platform
  1. Windows
I have an Excel application that reads and write to another Excel workbook that acts as a database.
The query is to select * when a record meets 2 criteria.
The selected record is then pasted onto a worksheet named [RECS]

From the enclosed image, you can see that the database (top image) record clearly contains data,
but the receiving worksheet (bottom image) does not have the data in fields W,X,Y.
What could be the problem?

VBA Code:
    '=========================
    '   Connect to database
    '=========================
    Set cn = CreateObject("ADODB.Connection")
    With cn
        .Provider = "Microsoft.ACE.OLEDB.12.0"
        .ConnectionString = "Data Source=" & dbpath & "\" & "DB.xlsx" & ";" & _
        "Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
        .Open
    End With
    
        '===================
        '   Run the query
        '===================
        strSQL = "SELECT * FROM [FS$] WHERE LotNo='" & Batch & "' AND MoldNo='" & Mold & "';"
        Set rs = cn.Execute(strSQL)
    
            '========================
            '   Show the result(s)
            '========================
            RECS.Rows("2:1048576").ClearContents
            RECS.Range("A2").CopyFromRecordset rs

Compare.jpg
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Fiddled with the data type in both workbooks:
Database - set to Text
Destination - set to General
Now the data in cols W,X,Y gets downloaded.

So maybe it is a data-type incompatibility issue.
Need to run a few more scenarios to confirm.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top