Results 1 to 8 of 8
  1. #1
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123

    Editing a table with form via VBA

    Hi I have a form to add, edit, and delete Records from a table
    I am using the following VBA

    Private Sub cmdEdit_Click()

    If Not (Me.frmlEmpDetailsSub.Form.Recordset.EOF And Me.frmlEmpDetailsSub.Form.Recordset.BOF) Then
    With Me.frmlEmpDetailsSub.Form.Recordset
    Me.txtAddEditname = .Fields("Name")
    Me.cboRoster = .Fields("Roster")
    Me.cboPermFctn = .Fields("PermFctn")
    End With
    End If
    End Sub

    Instead of refering to the Subform to load the data i would like to refer to a combobox:



    cboSearchName

    I hope its not an issue but This Combobox contains 5 columns

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123

    No, this is not the same thing
    all I need to do is change the recordset the the Edit fields refer to

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Change it to what? If a combo, isn't that

    Me.TextboxName = Me.ComboName.Column(2)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123
    do you mean replace

    If Not (Me.frmlEmpDetailsSub.Form.Recordset.EOF And Me.frmlEmpDetailsSub.Form.Recordset.BOF) Then
    With Me.frmlEmpDetailsSub.Form.Recordset

    With Me.TextboxName = Me.ComboName.Column(2)?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    I mean drop the recordset and the With statement and replace the 3 lines in the middle with references to the combo:

    Me.txtAddEditname = .Fields("Name")

    becomes

    Me.txtAddEditname = Me.ComboName.Column(2)

    with the appropriate column number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123
    Dont worry I worked It Out I was confused.
    Thank you.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 12-03-2013, 02:06 PM
  2. Replies: 3
    Last Post: 10-19-2013, 10:21 AM
  3. Editing Records In Table Using Form
    By ffezz in forum Programming
    Replies: 3
    Last Post: 03-14-2012, 01:40 AM
  4. Replies: 1
    Last Post: 05-17-2010, 12:03 PM
  5. Editing a Linked Table
    By amndza in forum Access
    Replies: 2
    Last Post: 01-21-2009, 01:27 PM

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