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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create data from subform to table?

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have a form that when it exits it runs this code:
Private Sub Form_Close()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim stDocName As String

stDocName = "qryPickupSubPlusQnty"

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPickupsSub", dbOpenDynaset)

If Me!frmPickupsOnCallSub![Quantity] > 1 Then

With rs
j = 1
For i = 1 To Me!frmPickupsOnCallSub![Quantity]
.AddNew
.Fields("PickupID") = Me![PickupID]
.Fields("ContainerID") = Me!frmPickupsOnCallSub![ContainerID]
.Fields("BarCode") = Me!frmPickupsOnCallSub![BarCode]
.Fields("ContainerName") = Me!frmPickupsOnCallSub![ContainerName]
.Fields("ContainerDescription") = Me!frmPickupsOnCallSub![ContainerDescription]
.Fields("Quantity") = 1
.Update
Select Case i
Case 4, 8, 12, 16: j = j + 1
End Select
Next i
End With

Set rs = Nothing
Set db = Nothing

Else

End If

DoCmd.OpenQuery stDocName
End Sub

The problem is that the data gets created for the last data row in the subform not all the information in the subform. How do I fix this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top