I am trying to write a program in VB6 with some issues. The part of the code attached symbolizes a check run on an Excel spreadsheet. If it has "Store" in the first column, first Cell, it warns that the file has already been parsed, and would then proceed to the Else statement, where it parses the file (the parsing code is not included as it works fine). My issue is if it finds it parsed, the message box appears warning the user as such. Answering "Yes" to the message box would begin the import process (starting with the If IntResponse = 6 Then). What I'm trying to get it to do it look at my database and run a query on a table to return a record count. If that record count is 0, I want it to run the import. If it finds any records, I want it to warn me it's already been imported. That's the part I can't working. I can get the import statement fine, but my check doesn't work. I'm very new to VB6 so I'm sure I'm doing something stupid. The code posted here will do everything EXCEPT query the database properly for the number of records. I would appreciate any and all insight into this.
If xlSheet.Range("A1").Value = "Store" Then
Dim intResponse As Integer
intResponse = MsgBox("WARNING!!! Import File has already been parsed. Click Yes to proceed with the import.", vbYesNo, "Warning")
If intResponse = 6 Then
' BEGIN IMPORT LOGIC HERE!!!!
Dim con As New ADODB.Connection
Dim adRs As New ADODB.Recordset
Dim TEST As Integer
Dim strSQL As String
Dim strSQL1 As String
strSQL = "INSERT INTO IMPORT SELECT * FROM [Sheet1$] IN ""R:\FTX Import\import.xls"" ""Excel 8.0; HDR=YES;"""
strSQL1 = "SELECT COUNT(*) As TEST FROM IMPORT;"
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\westy\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\FTXTranslator.mdb;Jet OLEDB:Engine Type=4")
adRs = con.Execute(strSQL1)
' Checks to see if records already exist in the destination table
If TEST = 0 Then
con = Nothing
MsgBox("Complete", vbInformation, "Done!")
Else : MsgBox("Already imported!", vbInformation, "Done")
con = Nothing