Results 1 to 5 of 5
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    save button

    Hi all
    Can I add a save button to the code



    Code:
    Private Sub Form_Load()
    On Error Resume Next
    
    
        Dim strOpenArgs As String
        Dim strTableName As String
        Dim strSQL As String
        Dim rs As DAO.Recordset
        Dim i As Integer
        Dim j As Integer
        
        strTableName = Split(Me.OpenArgs, "|")(0)
        strSQL = Split(Me.OpenArgs, "|")(1)
        
        Me.txtTableName = strTableName
        
        Set rs = CurrentDb.OpenRecordset(strSQL)
        If Not rs.BOF Then
            For i = 1 To 11
                If i <= rs.Fields.Count Then
                    j = i - 1
                    Me("Label" & i).Caption = rs.Fields(j).Name
                    Me("Label" & i).Visible = True
                    Me("Text" & i) = rs.Fields(j).Value
                    Me("Text" & i).Visible = True
                End If
            Next i
        End If
        rs.Close
        Set rs = Nothing
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    A save button would be a command button on form and the button has its own code.

    Maybe this procedure can have a line with command to save record. Never tried that in Load event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    What, in plain language, are you trying to accomplish, here?

    What are you trying to 'save?'

    Linq ;0)>

  4. #4
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you
    An organization based on fields of multiple tables. How do I save changes

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't understand the issue.

    Record is committed to table when:

    1. close table/query/form

    2. move to another record

    3. run code

    You have code opening a recordset and populating controls. Are these bound controls?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-20-2014, 03:25 PM
  2. form - save entered data only with save button
    By cbrxxrider in forum Forms
    Replies: 3
    Last Post: 10-20-2013, 12:39 PM
  3. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  4. VBA Save Button
    By Richie27 in forum Programming
    Replies: 8
    Last Post: 05-22-2012, 03:01 AM
  5. Save button
    By tia in forum Forms
    Replies: 19
    Last Post: 01-10-2012, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums