undo on an unbound form

icemonster

Registered User.
Local time
Today, 04:28
Joined
Jan 30, 2010
Messages
502
i found this code on the internet, i think it was roger's library. basically he made an undo code on an unbound form, it does work on this thing. but the key difference with his and mine is that i use a sql string to fill my record while he using a variable to open it. can anyone help me integrate his code with mine?

his code for form onload:

Code:
Private Sub Form_Load()
    On Error Resume Next
    Dim ct As Access.Control
    
    Set colCt = New Collection
    Set colCtVal = New Collection
    Set colFieldVal = New Collection
    
    ' Populate collection colCt with control objects
    ' representing unbound controls used for entering
    ' or editing data.
    ' Imp: All controls are named same as corresponding fields.
    For Each ct In Me.Controls
        If ct.ControlType = acTextBox Or _
                    ct.ControlType = acComboBox Then
            ' Exclude Pk control and excluded controls
            If ct.name <> PkFieldName And _
                            InStr(ExcludedFieldNames, _
                            "/" & ct.name & "/") = 0 Then   ' (B)
                colCt.Add ct, ct.name
            End If
        End If
    Next
    
    Set db = DBEngine(0)(0)
    Set rst = db.OpenRecordset(TableName, dbOpenDynaset)
    
    IsDirty = False
    DataMode = "Add"
    P_HighLight -2147483633
    P_DisableCmdBtns
    
    Set ct = Nothing
    
    ' Note - In statement (B), "/" separator is used at either end
    '            of the field name so as to prevent partial match.
    '            Alse see remarks at (A) in declarations section.
    On Error GoTo 0
End Sub

my function for setting the forms recordset:

Code:
Function startprogramdetails()

        strStartSql1 = "SELECT qry_program.id_program, qry_program.program_name, qry_program.program_abbr, qry_program.program_id_program_type, " _
                     & "qry_program.program_type_desc, qry_program.program_description, qry_program.program_createdon, " _
                     & "qry_program.program_createdby_id, qry_program.program_createdby_user, qry_program.program_createdat_ip, " _
                     & "qry_program.program_createdat_pc FROM qry_program "
                     
        strWhereSql1 = "WHERE qry_program.id_program = " & Forms![frm_main_menu]![lstprograms] & " "
        
        strSQL1 = strStartSql1 & strWhereSql1
               
        With Form_frm_details_program
            .RecordSource = strSQL1
            
         IDProgram = !id_program
         Me.program_name = !program_name
         Me.program_id_program_type = !program_id_program_type <-this also causes the field to be null, is it because they have the same name?
         Me.program_abbr = !program_abbr
         Me.program_description = !program_description
         Me.txtprogramid = 
        
        End With

End Function
 
well if i was only dealing with 1 recordset sure, but i am dealing with more than 1 table and using odbc connection for update and inserts. is there any way to do this with an unbound form?
 

Users who are viewing this thread

Back
Top Bottom