MS Access-textbox " aktualisieren/anfügen

Ich habe einige code füllt ein Textfeld namens text5 Forms!Form3!text5. Aber immer wenn ich auf den button klicken, welche updates Sie dieses Textfeld, es erfrischt es.

Möchte ich es so, dass der text unverändert bleiben soll, und fügen Sie die neuen Daten jedesmal, wenn der button angeklickt wird. Ich habe anbei der code, dass ich schon so weit

Option Compare Database

Private Sub Command0_Click()

  Set db = CurrentDb

  Dim I As Integer
  Dim varNumber As Integer  ' this takes the number for how many times to loop
  Dim strQueryName As String  ' this is for the sql to find lowest rack number
  Dim P  As Integer  'this value is the prod number
  Dim x As Integer   'value from lowestrackSQL



  varNumber = Me.Quantity 'box from form me means this form
  prodnumber = Me.ProdNo  'box from form

  strQueryName = "SQLToFindLowestRackNumber"   'this will be used to execute the query


  strSQL = CurrentDb.QueryDefs(strQueryName).sql   ' this stores the sql but does not run it

  Forms!form3!txtPrint = strResult
  'Stop

  For I = 1 To varNumber  ' uses the quntity value to count how many times to loop

    x = DLookup("locationrack", strQueryName)  'puts value of query into value x
    prod# = prodnumber

    'below puts into imediate view box
    Debug.Print "Line number = " & I; ";  Rack Location = " & x; ";   Product Number = " & prod#; ";"
    'below puts it into form3 text box
    strResult = strResult & " Line Number = " & I & " Rack Location = " & x & "   Product Numner = " & prod# & vbCrLf & ""
    Forms!form3!Text5 = strResult


    'below executes the SQL
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE [Location] SET [Location].ID = 0 WHERE [Location].RackID =" & x
    DoCmd.SetWarnings True

 Next I



End Sub   

Wie Sie sehen können den Wert des strResult übergeben wird, und das Textfeld möchte ich nur hinzuzufügen, halten Sie den Wert der text-box selbst wenn ich den Neustart der Schleife wieder.

InformationsquelleAutor Rob Hughes | 2012-07-06
Schreibe einen Kommentar