Question : Adding two different fields in two diferent records

I would like to add two field in different records.  I would like to do this is form or table view.  

Example:  sum(field1+ 1) in record1 and put it in field-x in record2.  
Then repeat this process.  It's a sequencing question.

Answer : Adding two different fields in two diferent records

Ahalim,

There are several ways to do this. You could query this parameters by using the Inbox-function, but a form gives you the most comfort. You could place three textboxes and a commandbutton on a form :

2. in textbox named txtStartVal you enter a startvalue
3. in textbox named txtAddVal you enter the value to be added ech time
4. in textbox named txtRows you enter the number of rows to populate the table with

After having entered all these values you can press the commandbutton named cmdMakeTable which fires this click-event:

Private Sub cmdMakeTable_Click()
On Error Resume Next
  Dim strSQL As String
  Dim rst As Recordset
  Dim lngIndex As Long
     
  With CurrentDb
    .TableDefs.Delete "tblSum"
    .Execute "CREATE TABLE tblSum " _
      & "(Sum NUMBER, Increment NUMBER);"
    Set rst = .OpenRecordset("tblSum")
  End With
   
  For lngIndex = 0 To txtRows - 1
    rst.AddNew
      rst!Sum = txtStartval + (lngIndex * txtAddVal)
      rst!Increment = txtAddVal
    rst.Update
  Next lngIndex
 
  If Err = 0 Then
    MsgBox "Table tblSum has been made succesfully."
  End If
 
End Sub

These textboxes might need a little more validation, but it gives you an idea.
Random Solutions  
 
programming4us programming4us