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

Access form tab clearning entire form when saving

Status
Not open for further replies.

tsb49

IS-IT--Management
Apr 21, 2008
9
US
I am working on a client information form with a general information/demographics on the tab and six tabs on the botton half for membership, activities, events, organizations, roles, and donations. It is based on a query consisting of the person and membership tables, and I have a save button to save the membership pricing to a transaction table for receipting purposes. Anyway, my problem is that the form when I click the save button the form is going to a new record as well and this I do not want to happen because the client may be registering for activities or events at the same time and so clearing the record entry could be extremely frustrating to front desk personnel when busy. I cannot not find anything in my code that is causing the new record change.
Here is the code:
Private Sub btnMbrshipSave_Click()
' Subroutine for adding new records to the memberships table from data entry form

' Creates variable for data recordsets
Dim rstMbrshipTransaction As DAO.Recordset
Dim rstSalesNumber As DAO.Recordset
Dim rstErrors As DAO.Recordset

' Sets up error handling for custom message box
On Error GoTo ErrorControl

' Initializes dataset record subset
Set rstMbrshipTransaction = CurrentDb.OpenRecordset("tblTransactions", dbOpenDynaset)
Set rstSalesNumber = CurrentDb.OpenRecordset("tblSalesNo", dbOpenDynaset)
Set rstErrors = CurrentDb.OpenRecordset("tblErrors", dbOpenDynaset)


' Check for Sales Receipt Number
If IsNull(Me.txtSalesRcptNo.Value) = True Then
Me.txtSalesRcptNo.Value = rstSalesNumber!SalesRcptNo
rstSalesNumber.Edit
rstSalesNumber!SalesRcptNo = Me.txtSalesRcptNo + 1
rstSalesNumber.Update
End If

' Adds and updates new record to transaction table from data entry form
With rstMbrshipTransaction
.AddNew
!PersonID = Me.txtPersonID.Value
!SalesRcptNo = Me.txtSalesRcptNo.Value
!transactionDate = Me.txtMbrshipOriginationDate.Value
!transactionItem = Me.cbxMbrshipTypeID.Value
!transactionDesc = Me.cbxMbrshipTypeID.Column(2)
!transactionQty = 1
!transactionRate = Me.txtMbrshipAmt.Value
.Update
End With
GoTo EndStatements

' Error handling for membership additions and sending error information to errors table
ErrorControl:
Call MsgBox("An error has occurred in Tigress. Please contact your Tigress Administrator.")
With rstErrors
.AddNew
!errorNumber = Err.Number
!errorDesc = Err.Description
!errorSource = Err.Source
!errorModuleName = "btnMbrshipSave_Click"
.Update
End With

EndStatements:
' Clears the data recordset
Set rstMbrshipTransaction = Nothing
Set rstSalesNumber = Nothing
Set rstErrors = Nothing

End Sub
Thank you so much any help you can provide.

tsb49
YWCA of Greater Lafayette
 
I had an idea about what could possibly be causing the problem but I was not sure about it at all. I looked to make sure that the button On Click event was set to event procedure rather than Embedded Macro (the default set by Access upon creation of the button in 2007), sure enough it was not even going into my code but treating the button like a Save and Next button. It appears to be working now that I changed it, although I will do more testing to be sure. Thanks for all your help.

tsb49
YWCA of Greater Lafayette
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top