Unanswered: Access 97 is adding the new record to top and bottom of table.
Im trying to do a simple add new record to a table from text boxes on a form. When I run the code is adds some of the fields into the first record and adds it fully into the last record.
Here is my code:
Private Sub cmdAdd_Click()
Dim dbsFish As Database
Dim rstProd As Recordset
Dim strProdID As Long
Dim strCatID As Long
Dim strCode As String
Dim strDescription As String
Dim strPieces As Long
Dim strRemarks As String
Set dbsFish = CurrentDb()
Set rstProd = dbsFish.OpenRecordset("tblProduct", dbOpenDynaset)
' Get data from the form.
strCatID = Me.CatID
strCode = Me.Code
strDescription = Me.Description
strPieces = Me.Pieces
strRemarks = Me.Remarks
'Run function with entered data
AddName rstProd, strCatID, strCode, strDescription, strPieces, strRemarks
'Close records after new entry
Function AddName(rstTemp As Recordset, strCatID As Long, strCode As String, _
strDescription As String, strPieces As Long, strRemarks As String)
' Adds a new record to a Recordset using the data passed
' by the calling procedure. The new record is then made
' the current record.
!CatID = strCatID
!Code = strCode
!Description = strDescription
!Pieces = strPieces
!Remarks = strRemarks
.Bookmark = .LastModified
I can get around it by using a macro to open the table and manually entering the data but this gives the user access to the table and I don't want them messing with that!.
All help appreciated.
T (My Access 97 Bible is on the way from America - but the mail system takes forever.!)
It sounds like the form is bound to the table, and displaying the first record at the point you begin this process. If so, the data entered at that point is actually editing the first record. The process you're going through would be more appropriate for an unbound form.