I want to open a form, let's call it fSelect, with some optional choices on it. If the operator makes a choice, that choice is saved to a control on the main form, and fSelect is closed.
However, I would like to close fSelect if the operator ignores it and continues to work on the main form.
fSelect cannot be Dialog, i.e. modal, or operator cannot ignore it.
LostFocus for fSelect doesn't seem to fire.
Deactivate fires, but attempts to close the form gets: - Run-time error '2585'
-
This action can't be carried out while processing a form or report event.
In other words, I can't close fSelect while processing the Deactivate event.
How can I close this form (fSelect) if it is opened and displayed, but not used?
use the DoCmd.Close acForm, "formname"
in the "active" event on the main form so that after selecting your option on form fselct when the next form opens insert the command into that forms "active" event.
so eg. form1 make aselection and call form2, when form2 opens its "active" event closes form1.
17 4812
DoCmd.Close acForm, "formname"
Do you want it to close after a certain amount of time, or when they begin to interact with the main form, or on some other trigger?
malcolmk -
Thanks, but this is what I'm doing now, with the result of Run-time error '2585' so the form doesn't close. Trapping the error hasn't worked either. I don't know what to do after it errors. Attempting again to close the form gets me into an infinite loop, or course.
gnawoncents -
I want to close the form ASAP (As Soon As Possible). I don't like timers because they're either too slow (long time) or they are too fast, and take action when operator is distracted.
The form has one control (Listbox named lbxSelect). I've tried setting lbxSelect.SetFocus and triggering the close on LostFocus. This event never fires if focus goes to the main form.
I've tried giving the form focus with Me.SetFocus or Me!SetFocus, but this doesn't fire either, probably because there is an enabled, visible control on the form.
Form_Deactivate fires, but then Run-time error '2585' when I try to execute the Close.
I will trigger off of ANY event that fires and permits me to close the form.
I use the following function for a different purpose but maybe it could help. Maybe you could run it when your Main form gets the focus and if the proposed function returns true then close the form... -
Function IsLoaded(ByVal strFormName As String) As Boolean
-
-
Const conObjStateClosed = 0
-
Const conDesignView = 0
-
-
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
-
If Forms(strFormName).CurrentView <> conDesignView Then
-
IsLoaded = True
-
End If
-
End If
-
-
End Function
-
-
You haven't adequately described when you want the form to close. Unless there is an event that you want to trigger the closing of the form, you would use the timer to determine how long it had not been used.
Why not let the user open the form modal if they need it?
The main form's GotFocus doesn't fire when a control is clicked. What fires is the control's GotFocus. This would entail using the GotFocus event for every control on the form, and checking for IsLoaded.
Normal navigation around the form would have this called almost continually for what was (I hoped) an infrequently used form.
What's the purpose of the form? When does it open?
The form consists of a listbox lbxSelect. The rowsource is an SQL statement with OpenArgs as the WHERE condition. There is only 1 column in lbxSelect.
Main program is a log. Many of the textboxes have similar entries. For example, the textbox txtReason might have 'Stop Service' or 'Complaint' or 'Dispute Bill' or 'Change' or something completely unique. I want, when this box is entered (tab or mouse) to have the list of common entries displayed for selection, or if operator chooses, they may ignore completely and enter something else, like '2nd request, cancel order'.
I originally tried a hidden listbox which I could set to .Visible. Works fine, when Clicked or LostFocus it is rehidden. Takes too much space vertically as it cannot cross a record boundry on a Continuous Form.
I can do this by hiding the form instead of closing, and changing lbxSelect.RowSource from the main form and unhiding. I already have many hidden forms, and this seems to slow the computer when switching between applications.
Why not hide/close the form on exit of the textbox that caused it to open?
That works well on the LostFocus event, but if the next control the user wants is 'under' the fSelect but not in tab order, then they must click in some other area of the main form to close fSelect. I might as well put a Close Button on fSelect and be direct about it.
My combo boxes extend over subsequent records in continuous form view. Are you using Access 2007?
I use Access 2003. I tried 2007 and didn't like. This is a listbox, not combobox, so not 'dropdown', which has different rules. I didn't use combobox as I didn't want entry in the text portion.
I had originally thought to use cascading comboboxes (2 levels) but this doesn't work on continuous forms for the same reasons that unbound controls (i.e. CheckBoxes) don't work. The value of combo1 of the current record applies to the RowSource for all combo2.
So different records require different lists of options in the same field? Otherwise you could use a combo box on the main form, instead of a text box. You can even call combobox.DropDown on enter to display your list when they tab into the field. The user can then click an item on the list or use autocomplete.
Yeah
Think States and Counties in the USA. Select state and the county list changes. Occasionally user might want to refer to something else, like 'All Counties' or in the case of Alaska, 'Not in a County'. Alaska calls them buroughs, but same logic.
So I need to use the field for standard as well as non-standard notations.
But this approach seems not to work well. Guess I'll just hide the form for now. Thanks for all the suggestions.
use the DoCmd.Close acForm, "formname"
in the "active" event on the main form so that after selecting your option on form fselct when the next form opens insert the command into that forms "active" event.
so eg. form1 make aselection and call form2, when form2 opens its "active" event closes form1.
Form couldn't be closed while handling Deactivate event, but it could be closed while handling Timer event. -
Private Sub Form_Deactivate()
-
Me.TimerInterval = 1
-
End Sub
-
-
Private Sub Form_Timer()
-
DoCmd.Close acForm, Me.Name
-
End Sub
-
Apparently this does work. Thank you. Closing an already closed form doesn't seem to cause an error, so other causes of activate not resulting from return from fSelect aren't a problem.
I say 'Apparently' because testing the Activate condition is difficult. Any attempt to use the debugging tools cause activate/deactivate to fire as the focus moves between the program forms and the debugger.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vivek Sharma |
last post by:
How can I close a form in C#?
Here is the code that I am using but closes everything?
private void frmSplash_Click(object sender, EventArgs e)
{
this.Close();
Form frmLogin = new...
|
by: dwilliamjoe |
last post by:
VB.net, launch procedure, close form, the whole APP is deactivated.
When I say deactivated, other applications (Wind Explorer, My computer,
Ect...) come to the foreground and my app goes to the...
|
by: AP |
last post by:
IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to...
|
by: Mindy |
last post by:
I have two questions here:
(1) what is the difference of close form and close table?
(2) How "Prompt" works
I used close form macro in my database. I hope when a user close the
form, he/she will...
|
by: jodyblau |
last post by:
I'm new at this stuff, so let me know if I am approaching this
incorrectly.
I have a form that allows the user to select a document that is in one
folder, and copy it into another folder. I...
|
by: Robert Dufour |
last post by:
On my form if the user clicks the upper right hand corner to close the form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.
...
|
by: freelancex |
last post by:
Hi, Im new to this forum, and new to scripting in general.
Im an ICT Technician for a high school and i am designing a Form in visual basic 2005. The intended purpose of the Form, is to prevent...
|
by: kev |
last post by:
Hi folks,
I have a form for registration (frmRegistration) whereby i have two
buttons. One is Save which saves record using the OnClick property. I
used wizard to create the save button. The...
|
by: AccessIdiot |
last post by:
Hello all,
I have a form (frm_Entrainment) with a button that opens a 2nd form (frm_Specimen_Entrainment). The 2nd form shares an ID field with the first form (Entrainment_ID - its like opening...
|
by: Hulas |
last post by:
Guys, I have two questions.
(a) How do I add two fields of the same table to a single combo box. For example if I have two fields ID1 and ID2 in a table called Identification, than how should I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |