Solved

Saving New Records

Posted on 2000-02-29
1
136 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 25 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now