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

rs.AddNew

Status
Not open for further replies.

DaveCrate

Technical User
Jan 12, 2004
41
US
Access 2007
I have a form that consists of a request date, supplier, and a txtbx_numberrecords to be added to request_table. I want to add 5 records from the form which includes today's date, supplier "A"

01/14/2009 A
01/14/2009 A
01/14/2009 A
01/14/2009 A
01/14/2009 A

currently the cmd button will update the table once but not the number of times I have in txtbx_numberrecords

Any help someone cna assisdt me with would be greatly appreciated

Thanks!
 
Sorry, Forgot the important part. It's been awhile since I 've posted
Thanks

Private Sub Button_New_Request_Click()

Dim varOrderLines As Integer '
Dim varSupplierList As Variant
Dim varRequestDate As Date

Dim rs As ADODB.Recordset
Dim intNumColumns As Integer
Dim intI As Integer
Dim frmCust As Form
varOrderLines = 0
Me.Order_Lines.SetFocus
varOrderLines = Me.Order_Lines.Text

varOrderLines = Forms!EnterNewRequest.Controls!Order_Lines.Value
MsgBox "The Order Lines equal " & varOrderLines

varRequestDate = Forms!EnterNewRequest.Controls!tbRequest_Date.Value
MsgBox "The Request Date equal " & varRequestDate

varSupplierList = Forms!EnterNewRequest.Controls!Supplier_List.Value
MsgBox "The supplier value equal " & varSupplierList

Set rs = New ADODB.Recordset

rs.Open "Select * from NewRequesttable", CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
Set frmCust = Forms!EnterNewRequest
If frmCust!Supplier_List.ItemsSelected.Count > 0 Then

' Any selection?
intNumColumns = frmCust!Supplier_List.ColumnCount
Debug.Print "The list box contains "; intNumColumns; _
IIf(intNumColumns = 1, " column", " columns"); _
" of data."

Debug.Print "The current selection contains:"
For intI = 0 To intNumColumns - 1
' Print column data.
Debug.Print frmCust!Supplier_List.Column(intI)
Next intI
Else
Debug.Print "You haven't selected an entry in the " _
& "list box."
End If

Set frmCust = Nothing

Dim NewSupplierRequest As String
Dim NewPORequest As String
Dim NewVendorRequest As String

NewSupplierRequest = Me!Supplier_List.Column(0)
NewPORequest = Me!Supplier_List.Column(1)
NewVendorRequest = Me!Supplier_List.Column(2)

rs.AddNew
rs.Fields("REQUESTDATE").Value = varRequestDate
rs.Fields("SUPPLIER").Value = NewSupplierRequest
rs.Fields("PO").Value = NewPORequest
rs.Fields("VENDOR").Value = NewVendorRequest

rs.Update

rs.Close

End Sub
 
something like


dim RecordsToAdd

RecordsToAdd=0

do until RecordsToAdd=txtbx_numberrecords
rs.AddNew
rs.Fields("REQUESTDATE").Value = varRequestDate
rs.Fields("SUPPLIER").Value = NewSupplierRequest
rs.Fields("PO").Value = NewPORequest
rs.Fields("VENDOR").Value = NewVendorRequest

rs.Update


RecordsToAdd=RecordsToAdd+1
loop
 
pwise,


Thanks, that's it! I appreciate it. I just brought this back to surface since 04. haven't quite gotten the cob webs out yet.

Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top