Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help Initializing strings

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
US
I have three strings defined in code that i need to initialize.&nbsp;&nbsp;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).&nbsp;&nbsp;My trouble is that after processing the first record in the table, when processing the next record, the &quot;strings&quot; still contain data from the first record key that was constructed.&nbsp;&nbsp;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).&nbsp;&nbsp;can someone help ?&nbsp;&nbsp;code i am using is below, <br>Thankyou so mucn ! <br>Paul<br>&nbsp;<br>Public Sub UpdateKey()<br><br>Dim db As DAO.Database<br>Dim rst As DAO.Recordset<br>Dim strSize As String<br>Dim strBoName1 As String<br>Dim strBoName2 As String<br>Dim bytCount As Byte<br>Dim bytPos As Byte<br>Dim strKey As String<br><br>Set db = CurrentDb<br>Set rst = db.OpenRecordset(&quot;SELECT * FROM AllItemsConsolidatedTable&quot;)<br><br>Do While Not rst.EOF<br><br>'Create Size string from field, eliminating spaces <br><br>&nbsp;&nbsp;&nbsp;&nbsp;For bytCount = 1 To Len(rst!BriefDescription)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Mid(rst!BriefDescription, bytCount, 1) &gt; &quot; &quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSize = strSize & Mid(rst!BriefDescription, bytCount, 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;Next bytCount<br><br>'Find where a &quot;'&quot; is and grab the first 8 characters of that<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;bytPos = InStr(rst![ItemName], &quot;'&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;If bytPos &lt;&gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strBoName2 = Mid(rst![ItemName], bytPos, 8)<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strBoName2 = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>'Create Botanical Name string without spaces (not working)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;For bytCount = 1 To Len(rst![ItemName])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Mid(rst![ItemName], bytCount) &lt;&gt; &quot; &quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strBoName1 = strBoName1 & Mid(rst![ItemName], bytCount)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;Next bytCount<br><br>'Grab what is left over of the botanical name (works)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;strBoName1 = Left(strBoName1, (30 - Len(strSize) - Len(strBoName2)))<br><br>'Assign the key string<br><br>&nbsp;&nbsp;&nbsp;&nbsp;strKey = strBoName1 & strBoName2 & strSize<br><br>'Edit the record<br><br>&nbsp;&nbsp;&nbsp;&nbsp;rst.Edit<br>&nbsp;&nbsp;&nbsp;&nbsp;rst!MAS90ITEMKEY = strKey<br>&nbsp;&nbsp;&nbsp;&nbsp;rst.Update<br><br>'move to the next record if there is one<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not rst.EOF Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>Loop<br><br>rst.Close<br>Set rst = Nothing<br>Set db = Nothing<br><br>End Sub<br><br>
 
I only glanced at this quickly but how about trying&quot;<br><br>'move to the next record if there is one<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If Not rst.EOF Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>strBoName1 = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strBoName2 = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSize = &quot;&quot;</font><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rst.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top