Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving New Records

Posted on 2000-02-29
1
Medium Priority
?
146 Views
Last Modified: 2010-05-02
I am working on a project, and the following code is supposed to save a new record. Instead it deletes and replaces the first record then adds a new record to EOF. Please help as my job is on the line(no joke), and as a newcomer this problem is driving me bonkers.

Code Begins:

Private Sub cmd_Save_Click()
Dim rs As Recordset
Set rs = Data1.Recordset

Data1.ReadOnly = False

       
strTypeOfInquiry = cmboTypeOfInquiry.Text
strStatus2 = cmboStatus.Text
T_TimeInteracting = Input_TimeSpentInteraction.Text
Dte_DateEntered = txt_DateEntered.Text
Dte_DateInteraction = txt_DateInteraction.Text
strNotes = txtNotes.Text
strAuthor = cmbo_Author.Text
num_ClientInteractions  = rs.RecordCount

'ClientInteraction.Data1.Recordset.EOF
ClientInteraction.Data1.Refresh

With Data1.Recordset

            'rs.MoveLast 'I THOUGHT THIS WOULD WORK BUT IT DIDN'T
            .AddNew  
            !Number_Client = strBBINumber
            If num_ClientInteractions  > 0 Then
                  !Client_Interactions = num_ClientInteractions + 1
            Else
                  !Client_Interactions = 1
            End IF
            !TypeOfInquiry = strTypeOfInquiry
            !Status = strStatus2
            !Date_Interaction = Dte_DateInteraction
            !DateEntered = Dte_DateEntered
            !Note = strNotes
            !InteractionAuthor = strAuthor
            !TimeSpentOnInteraction = T_TimeInteracting
       
            .Update
            'Data1.Recordset.Update

            ClientInteraction.cmdSaveAndExit.Enabled = False

        End With

        ClientInteraction.Data1.Recordset.Close
   
    End If

End Sub

CODE ENDS. Please help. Thank you.
0
Comment
Question by:dingo11
1 Comment
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 2575277
The code I've always used for adding a record is as follows:

Data1.Recordset.AddNew
Data1.Recordset.Fields("fieldName") = SomeText.Text
Data1.Recordset.Fields("field2Name") = MoreText.Text
 
 etc...


Data1.Recordset.update
Data1.Refresh

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question