belovedcej
Programmer
I have an unbound form that I want to load with one record. The record is selected based on a selection made in a list box on a previous form.
Then changes can be made to the data.
Then I want to click the save button which runs a stored procedure to update the table with the new data.
I have successfully loaded the form with only the one record. But then when I hit save it tries to update twice and gives me a warning - it saves through the stored procedure and then tries to save again as the form closes. (I think - I get a warning that says another user has changed the record and do I want to overwrite the changes.) I think it's because right now I load it with a view.
Can anyone advise me?
Here is the code that opens the form and gives it the recordsource.
Here is the code I use to save with:
Then changes can be made to the data.
Then I want to click the save button which runs a stored procedure to update the table with the new data.
I have successfully loaded the form with only the one record. But then when I hit save it tries to update twice and gives me a warning - it saves through the stored procedure and then tries to save again as the form closes. (I think - I get a warning that says another user has changed the record and do I want to overwrite the changes.) I think it's because right now I load it with a view.
Can anyone advise me?
Here is the code that opens the form and gives it the recordsource.
Code:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCaseTypeEdit"
stLinkCriteria = Me.listCaseTypes
DoCmd.OpenForm stDocName
Form_frmCaseTypeEdit.RecordSource = "Select Case_Type_ID, Case_Type_VC, Case_Type_Description_VC FROM dbo.MED_Case_Type_V WHERE Case_Type_ID = " & stLinkCriteria
DoCmd.Close acForm, "frmCaseTypes"
Here is the code I use to save with:
Code:
Dim Case_Type_ID As Integer
Dim Case_Type_VC As String
Dim Case_Type_Description_VC As String
Dim Deleted_B As Byte
Dim rst As New ADODB.Recordset
Dim cmd As New ADODB.Command
Case_Type_ID = Me.intCaseTypeID
Case_Type_VC = Me.txtCaseType
Case_Type_Description_VC = Me.txtCaseTypeDescription
Deleted_B = "0"
With cmd
.ActiveConnection = CurrentProject.BaseConnectionString
.CommandType = adCmdStoredProc
.CommandText = "dbo.MED_UPDATE_Case_Type_T"
.Parameters.Refresh
.Parameters(1) = Case_Type_ID
.Parameters(2) = Case_Type_VC
.Parameters(3) = Case_Type_Description_VC
.Parameters(4) = Deleted_B
Set rst = .Execute
End With
DoCmd.OpenForm "frmCaseTypes"
DoCmd.Close acForm, "frmCaseTypeEdit", acSaveNo