Full Version: Command button to open form in Add Mode
UtterAccess Forums > Microsoft® Access > Access Forms
Kento
Hi All,
I've made a command button to open a form, how do I apdat the code so the form opens in Add mode?
THere is the code:
Private Sub commandOpenFormAddPostCodeLocalAuthority_Click()
On Error GoTo Err_commandOpenFormAddPostCodeLocalAuthority_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddPostCodeLocalAuthority"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_commandOpenFormAddPostCodeLocalAuth:
Exit Sub
Err_commandOpenFormAddPostCodeLocalAuthority_Click:
MsgBox Err.Description
Resume Exit_commandOpenFormAddPostCodeLocalAuth

End Sub
Cheers,
Sam.
ScottGem
DoCmd.OpenForm stDocName, , , stLinkCriteria,acFormAdd

BTW, if you had just add a comma, Intellisense would have shown you what to do. Also, looking up the OpenForm method in Access VBA Help would have gotten you an anwer.
Alan_G
Hi
hange this line
DoCmd.OpenForm stDocName, , , stLinkCriteria
to
DoCmd.OpenForm stDocName, , , stLinkCriteria , acFormAdd
Kento
Thanks both,
uch appreciated.
Sam.
Alan_G
You're welcome - glad we could help
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.