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!

Subform Recordsource base on Temp Table

Status
Not open for further replies.

MelissaKT

Technical User
Jun 22, 2004
95
US
I have an unbound form that I need to put a subform on. I need to be able to undo any changes that a user might make.
thread705-769981 talks about EXACTLY what I'd like to do

You can use a temp table to store the values from the main/sub form. Then if the user cancels, you simply update the table with the stored values.

Would this work since the DB is going to be in a multi user environment? AND how exactly do I do this? If I'm unable to do this, is there a way to undo the changes that a user makes to a subform? Thank you in advance.
 
I've started to use the rollback transaction code that is located in the Access Developer's Handbook. I would like to modify it for ADO. I'm getting an error and I was wondering if you could point out what I'm doing wrong.
Code:
Private Sub ResetData()

On Error GoTo HandleErrors
    Dim rst As New ADODB.Recordset
    Dim param As New ADODB.Parameter
    Dim cmd As New ADODB.Command
    Dim cnn As New ADODB.Connection
    
    Set cnn = CurrentProject.Connection
           
    ' Assume user wants to commit changes in subform,
    '  if they haven't canceled them.
    If mfInTrans Then
        cnn.CommitTrans
    End If
    
    ' Create and assign filtered recordset for subform.
    Set cmd.ActiveConnection = cnn
    Set param = cmd.CreateParameter("PONUMBER", adInteger,  adParamInput)
    cmd.Parameters.Append param
    param.Value = Me.txtPONumber
    'set up a command object for the stored procedure
    cmd.CommandText = "spSubformEdit"
    cmd.CommandType = adCmdStoredProc
    'Execute the command and return results to recordset
    Me.Painting = False
    Set rst = cmd.Execute
    Set Me.fSubEditFormSubform.Form.Recordset = rst
    Me.Painting = True
    
    'Start a new subform transaction
    cnn.BeginTrans
    mfInTrans = True
ExitSub:

Exit Sub
HandleErrors:
MsgBox "Error Number " & Err.Number & " " & Err.Description

End Sub

It seems to work - I think (I haven't tried to actually roll something back - I'm still working on the recordset itselft) however, the recordset that it returns is read only. What am I doing wrong?
 
Also, since I've switched the recordsource to a stored procedure, I'm getting an error that says "class not registered". I'm not sure where it is bugging out. Any ideas? Thanks for any help in advance!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top