Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Code to Test Condition and Save Record to Excel

I have the following schema:

[ARDC.txt]
Format=FixedLength
ColNameHeader=False

Col1=DocID Text Width 6
Col2=Space2 Text Width 2
Col3=Date Date Width 8
Col4=Space4 Text Width 2
Col5=Type Text Width 20
Col6=Space6 Text Width 1
Col7=Status Text Width 11
Col8=Space8 Text Width 1
Col9=TT Text Width 4
Col10=Space10 Text Width 1
Col11=ClAmt Text Width 11
Col12=BillAmt Text Width 11

I have the following code:

Option Explicit
Sub OpenRSFromText()
Dim oConn As ADODB.Connection
Dim rsInput As ADODB.Recordset
Dim strPath As String

strPath = "F:\DATA\XCELData\MACROS\AR\"
Set oConn = New ADODB.Connection
Set rsInput = New ADODB.Recordset

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath & ";" & _
"Extended Properties=""text;HDR=NO;FMT=FixedLength"""

rsInput.Open "SELECT * FROM ARDC.txt", _
oConn, adOpenStatic, adLockOptimistic, adCmdText

....need help here...

End Sub

I want to test each record from ARDC.txt. If ClAmt < BillAMT, I want to
copy that record into my workbook.

1. Can I/should I define the ClAmt and BillAmt fields as numbers? (Double
precision)
If so, How?

2. What code would I use in the macro to test the condition and copy the
records into Excel?

TIA.
--
Ken Hudson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP! Need to have earliest test record data Lee Excel Discussion (Misc queries) 2 July 27th 09 05:24 PM
EXTRACTING UNIQUE RECORD BASED ON CONDITION SSJ New Users to Excel 6 April 19th 07 04:53 AM
EXTRACTING UNIQUE RECORD BASED ON CONDITION SSJ Excel Worksheet Functions 6 April 19th 07 04:53 AM
record an excel macro, save on network so that everyone can access Conajo Excel Discussion (Misc queries) 5 February 10th 05 11:50 PM
How do I save a record from an excel template to a database in a . Fred Smith Excel Discussion (Misc queries) 1 November 30th 04 01:49 PM


All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"