Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need help Initializing strings

Need help Initializing strings

Need help Initializing strings

I have three strings defined in code that i need to initialize.  in these three strings i am building a record key from data in an access table that will be used in another system (MAS90 accounting system).  My trouble is that after processing the first record in the table, when processing the next record, the "strings" still contain data from the first record key that was constructed.  i think i need to clear these strings out before starting on the next record but i am not a coder and don't know how to do this (can't find the instruction that does this).  can someone help ?  code i am using is below,
Thankyou so mucn !
Public Sub UpdateKey()

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSize As String
Dim strBoName1 As String
Dim strBoName2 As String
Dim bytCount As Byte
Dim bytPos As Byte
Dim strKey As String

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM AllItemsConsolidatedTable")

Do While Not rst.EOF

'Create Size string from field, eliminating spaces

    For bytCount = 1 To Len(rst!BriefDescription)
        If Mid(rst!BriefDescription, bytCount, 1) > " " Then
            strSize = strSize & Mid(rst!BriefDescription, bytCount, 1)
        End If
    Next bytCount

'Find where a "'" is and grab the first 8 characters of that
   bytPos = InStr(rst![ItemName], "'")
    If bytPos <> 0 Then
        strBoName2 = Mid(rst![ItemName], bytPos, 8)
        strBoName2 = ""
    End If

'Create Botanical Name string without spaces (not working)

    For bytCount = 1 To Len(rst![ItemName])
        If Mid(rst![ItemName], bytCount) <> " " Then
            strBoName1 = strBoName1 & Mid(rst![ItemName], bytCount)
        End If
    Next bytCount

'Grab what is left over of the botanical name (works)

    strBoName1 = Left(strBoName1, (30 - Len(strSize) - Len(strBoName2)))

'Assign the key string

    strKey = strBoName1 & strBoName2 & strSize

'Edit the record

    rst!MAS90ITEMKEY = strKey

'move to the next record if there is one

    If Not rst.EOF Then
    End If

Set rst = Nothing
Set db = Nothing

End Sub

RE: Need help Initializing strings

I only glanced at this quickly but how about trying"

'move to the next record if there is one

    If Not rst.EOF Then
        strBoName1 = ""
        strBoName2 = ""
        strSize = ""

    End If

RE: Need help Initializing strings


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close