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!
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!
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 & "'"
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
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.
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!!!