473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

String variable in DoCmd.Close

Good morning everybody,
I'm trying to use a string variable inside the DoCmd.Close statement. Despite many attempts this doesn't work. Does anybody have a solution for that?

I have a form called frmFunctMod1 (there will be more forms like this, this is why I need to use the name as variable). Here is my (non-working) code trying to close the form:

Expand|Select|Wrap|Line Numbers
  1.  
  2. strModuleNameFull = "frmFunctMod1"
  3. Debug.Print "check string name", strModuleNameFull
  4. DoCmd.Close acForm, " ' &  strModuleNameFull & ' ", acSaveYes
Thanks in advance for any help!
Mar 23 '10 #1
5 3692
NeoPa
32,556 Expert Mod 16PB
You are passing the string name itself, with the SQL quote chars (') and the ampersands (&) as the string.

The parameter passed to DoCmd.Close will be literally :
Expand|Select|Wrap|Line Numbers
  1. ' & strModuleNameFull & '
Actually, DoCmd.Close will close the active window if no parameter is passed, so I'd recommend instead :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.Close(Save:=acSaveYes)
Mar 23 '10 #2
Excellent, it works!
Thank you very much for the response. Actually I have a drop-down menu with several mathematical functions used later on for columnar calculations. Everytime somebody selects in the menu the function to apply, it opens a short function description form. When the selection is changed in the list, the old description form closes and the new one is opened. Before I couldn't close the opened forms. Now it proceeds smoothly.

Thanks again.

Marcin
Mar 23 '10 #3
NeoPa
32,556 Expert Mod 16PB
I'm very pleased to hear it Marcin :)

By the way, most procedures and other items have an associated Help page that will give you a lot of helpful information. Simply put the cursor in the word you're interested in and press F1. This brings up Context-Sensitive help about the current word.

EG. Press F1 when cursor anywhere within Close.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close
Mar 23 '10 #4
Thanks!
This is cool. I didn't notice that I could directly get help this way.

M.
Mar 23 '10 #5
NeoPa
32,556 Expert Mod 16PB
More than cool. I couldn't live without context-sensitive help.

Have fun :)
Mar 23 '10 #6

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

Similar topics

3
by: Iain Miller | last post by:
I'm sure this ought to be simple but I can't make it work!! I have a form (based on a query) that holds information about an individual. Each individual has a Unique reference field called...
3
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
3
by: carl.barrett | last post by:
Hi, I have a number of buttons on a form which run mailmerges. Next to each button is a text box/control that the user enters a date into when the letter was created/merged. When the user...
9
by: keliie | last post by:
Hello (from Access novice), I'm building a switchboard form (using a Treeview object). The treeview is populated by two tables (tblSwitchboardParent and tblSwitchboardChild). Within...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
3
by: Dave | last post by:
Hello, I have a pop-up form that is used to enter data on a form that is already open. My difficulty is that any of several forms might call this same pop-up, meaning that I need to store the...
2
by: RICHARD BROMBERG | last post by:
I have a string variable that is presently being sent to a MessageBox. I want to add a command button to the Form so I can send the string variable directly to the printer. Is there a simple...
9
by: Andy | last post by:
Just noticed something interesting in the above. If you have your program file set to "Compact on Close" in access 2007 (which is desirable when you have a larger program that frequently needs...
2
by: KingKen | last post by:
I have the following logon modules which I used to direct users with varying priviledges to log on to the DB. I want to be able to populate my support log form with the user ID once the user logs on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.