Results 1 to 5 of 5
  1. #1
    adiaz1129 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    3

    Open Form to a specific record to edit

    Need help, would like to open a form in edit mode, prompting user for record to edit.



    DoCmd.OpenForm "Test Form" > prompts user input for ID# to edit.

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    make a form with a text box, user enters the #.
    a button to open the form

    for numeric:
    docmd.openform "test form",,,"[id]=" & me.txtBox

    for string:
    docmd.openform "test form",,,"[id]='" & me.txtBox & "'"

  3. #3
    adiaz1129 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    3
    I'm attempting to add below SQL query to code below, so that when it opens the form it will prompt for the ID to edit.

    SELECT tbl_EQT_List.*
    FROM tbl_EQT_List
    WHERE (((tbl_EQT_List.eqtEquipmentID)=[eqtEquipmentID:]));




    Private Sub cmd_eqt_Edit_Eqt_Save_Click()
    On Error GoTo cmd_eqt_Edit_Eqt_Save_Click_Err

    On Error Resume Next

    If (Form.Dirty) Then
    DoCmd.RunCommand acCmdSaveRecord
    End If

    If (MacroError.Number <> 0) Then
    Beep
    MsgBox MacroError.Description, vbOKOnly, ""
    Exit Sub
    End If

    On Error GoTo 0
    DoCmd.Close , ""
    DoCmd.OpenForm "frm_eqt_Edit_Eqt", acNormal, "", "", acEdit, acNormal

    cmd_eqt_Edit_Eqt_Save_Click_Exit:
    Exit Sub
    cmd_eqt_Edit_Eqt_Save_Click_Err:
    MsgBox Error$
    Resume cmd_eqt_Edit_Eqt_Save_Click_Exit

    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Don't use parameter popup input prompts in query. Cannot validate user input.

    If you do want to use them then the query would be the form's RecordSource.

    Did you try what ranman suggested?

    Review http://allenbrowne.com/ser-62.html
    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.

  5. #5
    adiaz1129 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2018
    Posts
    3
    I was actually going to create a search form.
    But since the user will always know the ID# of record to edit, I've decided to just save the query and use the query in FilterName argument.
    DoCmd.OpenForm stDocName, , "qry_Prompt_eqtID", , acFormEdit, acWindowNormal



    Thanks!!!




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

Similar Threads

  1. Open form with specific record
    By Lukael in forum Programming
    Replies: 14
    Last Post: 11-16-2015, 06:31 AM
  2. Open form to specific record
    By zoro.1983 in forum Access
    Replies: 3
    Last Post: 05-31-2015, 11:04 AM
  3. Replies: 4
    Last Post: 12-22-2014, 11:07 AM
  4. Open form on specific record
    By iky123 in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 09:56 AM
  5. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 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