By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

update recordset

100+
P: 158
I'm using 2 forms one is a customer entry form and the second is an invoice entry form for that particular customer. I'm sending the invoice form the customer id number to keep the link up. The form is set as a continuous form and what i am having the user do is press a button to add a new record. For example the customer needs a piece of equipment and the accessory to that equipment. This would be on two lines (records) in the continuous form. The code that i am doing this with works, i just need to "update" or refresh the form to display the new record.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command22_Click()
  2. Dim rsInvoice As ADODB.Recordset
  3. Set rsInvoice = New ADODB.Recordset
  4.  
  5. rsInvoice.Open "tblInvoice", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdTable
  6.   If (Not (rsInvoice.EOF)) Then
  7.     rsInvoice.MoveLast
  8.   End If
  9.   If (rsInvoice.Supports(adAddNew)) Then
  10.     With rsInvoice
  11.       .AddNew
  12.       .Fields("InvoiceNum") = varInvoiceNumber
  13.       .Fields("FreightCompany") = varFreightCompany
  14.       .Fields("AgentRef") = varAgentRef
  15.       .Fields("ProNumber") = varProNumber
  16.       .Update
  17.     End With
  18.   End If
  19.  
  20. rsInvoice.Close
  21. Set rsInvoice = Nothing
  22.  
  23. Me.Refresh
  24. Me.Repaint
  25. End Sub
Thanks in advance!
Sep 5 '08 #1
Share this Question
Share on Google+
2 Replies


RuralGuy
Expert 100+
P: 375
A Requery is needed in order for a RecordSet to pick up or drop any new or deleted records. A Refresh simply updates current records in the RecordSet.
Sep 5 '08 #2

100+
P: 158
A Requery is needed in order for a RecordSet to pick up or drop any new or deleted records. A Refresh simply updates current records in the RecordSet.

You are awesome! thanks bunches!
Sep 5 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.