423,851 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

Unload/close a popup form after updating

P: 3
I am new in access so any help would be very much appreciate.
I have a popup form, frmAddComposerWork, which is open with Data Entry set to Yes, where there are 2 text boxes: One for the composer name and the other for the Work title.
After filling the last text box, when I hit ENTER (to update the table behind with the new record) I want to close the form as well. I have tried several events on which I added the following VBA instruction:

DoCmd.Close acForm, Me.frmAddComposerWork

However, the form stays open and is prone to receive a new record (which I do not want at all).

I am sure that this is very simple, but I have being scratch my head all the week and I haven't find the answer. Can someone help? Thank you
Aug 10 '18 #1

✓ answered by zmbd

This is not "Strange Behavior" by any means because the syntax is incorrect:

DoCmd.Close ObjectType:=acForm,ObjectName:=Me.Name Save:=acSaveNo
You have to pass the name of the form as a string or by referencing the name property of the form which returns a string with the form's name.

IMHO: Get ditch the Macro - USE VBA

Sending you a copy of my Reference Boilerplate in your Bytes.com InBox

Share this Question
Share on Google+
6 Replies


100+
P: 100
You could always add a command button to your pop up form that will close the form once you click on it. Using VBA or even the command button wizard.
Aug 10 '18 #2

P: 3
DJRhino1175, thank you for your suggestion.
Making a button with the wizard to close the form then it works perfectly. But if I do a button and trigger the Docmd Close with the click event it does nothing! It is a very strange behavior.
Aug 10 '18 #3

zmbd
Expert Mod 5K+
P: 5,285
This is not "Strange Behavior" by any means because the syntax is incorrect:

DoCmd.Close ObjectType:=acForm,ObjectName:=Me.Name Save:=acSaveNo
You have to pass the name of the form as a string or by referencing the name property of the form which returns a string with the form's name.

IMHO: Get ditch the Macro - USE VBA

Sending you a copy of my Reference Boilerplate in your Bytes.com InBox
Aug 10 '18 #4

P: 3
Thank you @zmbd. It solved the issue, and now I can leave the form immediately after updating the last text box, which was the original aim.
Aug 11 '18 #5

zmbd
Expert Mod 5K+
P: 5,285
a side conversation about Named vs Un-named arguments in code was moved to its own thread here: https://bytes.com/topic/access/answe...arguments-code
Aug 11 '18 #6

zmbd
Expert Mod 5K+
P: 5,285
GreenLion

!Two-Thumbs-Up!
Aug 11 '18 #7

Post your reply

Sign in to post your reply or Sign up for a free account.