Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 497177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:45:24+00:00 2026-05-13T05:45:24+00:00

Hi i have a recordset name rcdDNE. I read the rtn, accno, first name,

  • 0

Hi i have a recordset name rcdDNE. I read the rtn, accno, first name, Middle name, last name, amount, from text file and store it to the recordset. Now I want to store that values to database table. In my table accno is primary key. So before storing that into my table i want to find out if there is any duplicate accno in my recordset. If i have i want to write it to text file.

Can anyone help me.

' Set up rcdDNE structure
With rcdDNE.Fields
    .Append "RTN", adVarChar, 9
    .Append "AccountNbr", adVarChar, 17
    .Append "IndividualName", adVarChar, 22
    .Append "FirstName", adVarChar, 50
    .Append "MiddleName", adVarChar, 1
    .Append "LastName", adVarChar, 50
    .Append "Amount", adCurrency
End With

rcdDNE.Open
intFileNbr = FreeFile(1)
Open strFileName For Input As #intFileNbr Len = 95 ' Open file for input.
Do While Not EOF(intFileNbr)
   Line Input #intFileNbr, strCurrentLine
   If Mid(strCurrentLine, 1, 1) = 6 Then
     strRoutingNbr = Mid(strCurrentLine, 4, 8)
     strAcct = Trim(Mid(strCurrentLine, 13, 17))
     strIndividualName = Trim(Mid(strCurrentLine, 55, 22))
     strAmount = Trim(Mid(strCurrentLine, 30, 10))
     strAmount = Left(strAmount, Len(strAmount) - 1)
     curAmount = CCur(strAmount)

   ' Add new record to temporary recordset
        With rcdDNE
            .AddNew
            .Fields![RTN] = strRoutingNbr
            .Fields![AccountNbr] = strAcct
            .Fields![IndividualName] = strIndividualName
            .Fields![Amount] = curAmount
            .Update
        End With
   End If
Loop

‘ Write records to Database

frmDNELoad.lblStatus.Caption = "Loading data into database......"
Dim lngRecCount As Long
lngRecCount = 0
rcdDNE.MoveFirst

 With cmdCommand
    .ActiveConnection = objConn
    .CommandText = "insert into t_DATA_DneFrc (RTN, AccountNbr, FirstName, MiddleName, LastName, Amount) values ('" & rcdDNE("RTN") & "', '" & rcdDNE("AccountNbr") & "', '" & rcdDNE("FirstName") & "', '" & rcdDNE("MiddleName") & "', '" & rcdDNE("LastName") & "', '" & rcdDNE("Amount") & "')"
    .CommandType = adCmdText
End With

Set rcddnefrc = New ADODB.Recordset
With rcddnefrc
    .ActiveConnection = objConn
    .Source = "SELECT * FROM T_DATA_DNEFRC"
    .CursorType = adOpenDynamic
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .Open
End With

Do Until rcdDNE.EOF
    lngRecCount = lngRecCount + 1
    frmDNELoad.lblStatus.Caption = "Adding record " & lngRecCount & " of " & rcdDNE.RecordCount & " to database."
    frmDNELoad.Refresh
    DoEvents
    Call CommitNew
    rcdDNE.MoveNext
Loop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:45:24+00:00Added an answer on May 13, 2026 at 5:45 am

    In the loop, where reading the data from the text file, Build a list of accno.

    Each time you read a line from the text, first check if the list contains the accno, if not, add the record, and add the accno to the list.

    If it does contain the accno in the list already, dont add the line to the record set and move to the next line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a select-case that will read a name field from a recordset,
I Have recordset rc1 that reads values from txt file. The fields are rtn
I have craeted code which reads the acc no, rtn, name and amt from
Okay I have a queswtion about returning the recordset from multiple stored procedures. If
If I were to have a recordset that just returned: SELECT * FROM USERS
Say we have 3 records in table: orig_tab --------------------------------------------- | PK | Name |
If I have 2 records with same information with difference in NAME of upper
for example, I have a textfield, that records the user name, after I click
I have table with following structure and records. table t1 +------+-------------+---------------------+ | name |
I have a recordset loop that creates a table, and every 9 items it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.