Modules & VBA :: Removing Form Instance From Collection Does Not Close Form
Nov 17, 2014
I am using the method from allen browne [URL] .... to open a form and add it to a collection and when removing it it closes. actually, usually it does work so but i have now a form which does not close until i am hitting the reset button in VBE , is there something i could check why it's not functioning as desired ?
Just to add, this form has a subForm as well (might be the cause ?)
my code does the following, user selects excel file, opens it, renames sheets, basically needs first sheet to be sheet1. rest don't matter Changes the formats in column a to number and 15dp, saves the file as .xls and then links the file to the database.
Code: Private Sub Command288_Click() Dim s As String Dim i As Long
I have two problems excel instance does not close at the end and two when I try to do the looking using text it works but soon as I try using date/time it returns nothing.
Code: Private Sub Command84_Click() Dim objExcel As Excel.Application On Error Resume Next
How to set focus to a non Default instance of a form.
Environment A2007 ADP Project Document Window Option - Tabbed Documents MS SQL 2012 Express DB Windows 7 64 Bit
I using Allen Browne's method to open more that one version of form, storing each form object in a collection declared in a module. No problem there.
Now I'm trying to add a command button on an form to set focus to one of these non-default instances already open.
The form I am trying to set focus to has a the following related properties
Default View: Split Form Pop-up: No Modal: No
The form that has the command button on it is of the same type.
Here is the code I've tried:
'Code on Calling Form Private Sub cmdProjectList_Click() Dim FunctionResult As Boolean
If AppForms.GoToForm("ProjectList") = False Then AppForms.Load_ProjectList
[Code] .....
The code compiles and executes with seemingly no problems. It finds the form loaded, then cycles though and finds the form in Forms but the SetFocus call seems to do nothing. When I run the code against a defualt instance ( one not opened using Allen Browne's method) it works fine and sets focus to it as expected.
I have a timer form which closes the database after a period of time with DoCmd.Quit. Another form is open at this point but if a user has left it in the middle of editing it I want to be able to save the record in the other form and close it before the timer form closes the database.
What VBA do I need in the timer form to save the record and close the other form before DoCmd.Quit? Just to be clear the code is...
Private Sub Form_Timer() On Error Resume Next Me.Tag = Val(Me.Tag) - (Me.TimerInterval / 1000) Me.Caption = "The database will exit in " & Me.Tag & " seconds" If Val(Me.Tag) <= 0 Then
I have a form I want to close but somehow the codes running before it cancel it out before my closing code can run.
Here is the full code for the form.
Code: 'Check for Null Fields If IsNull(Me.cmb_to_customer) Or IsNull(Me.cmb_from_customer) Then MsgBox ("Please enter a TO CUSTOMER and FROM CUSTOMER to continue.") Cancel = True
[Code] .....
This is the ending code that will not run:
'''''''''''''''''''''''''''''''' 'Continue or Not, If yes then wipe all fields, If no then exit form If MsgBox("Do you want to log-in/transfer more batteries?", vbOKCancel, "BATTERY LOG-IN/TRANSFER") = vbCancel Then DoCmd.Close acForm, "FRM_LOGIN" Else Me.cmb_from_customer = Null
All i want to do is after executing the following code, close the form " EmployeeFind" on completion?
Private Sub Form_DblClick(Cancel As Integer) On Error GoTo Err_Form_DblClick Dim stDocName As String Dim Msg, Style, Title, Response Msg = "Employee allocated to Job" Style = vbOKCancel + vbInformation Title = "Employee moved" ' Define title. Response = MsgBox(Msg, Style, Title) If Response = vbOK Then
In the main form I have a list box, when I right click on each item on list box another form "frmshortcut" (pop up) will be open in the position of mouse that shows a list box for selecting items according to below code, now I would like when select another place (except "frmshortcut"), this form automatically will be close, like what we have in shortcut list of windows. Now when right click it is opened in the location of mouse click, but problem is, it is not closed automatically when click in other places of main form.
Option Explicit Private Type POINTAPI x As Long y As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private mp As [*clsMousePosition]
I have a subform that is used in multiple other forms. I wish to have a command button that will close whichever main form the subform is in. Is there some way I can make an if statement that is something like the following?
If (main form = A) then Close (form A) ElseIf (main form = B) then Close (form B) etc. End if
Unfortunately the button has to be in the subform, not the main form (which would be easier). The purpose of the button is to delete the current records that are open and then close the form. The catch is that the subform is the parent record to the main form, so the command has to originate from the subform so that the cascade delete works properly.
I have a form I would like to close without saving the record using a button. here is the code I have but it closes the form and it also writes the record to the table.
Code: Private Sub ClosewoSave_Click() Cancel = True Me.Undo DoCmd.close DoCmd.OpenForm "frmMenu" End Sub
I found in a thread that Cancel = True would not write the record.
I have a problem when I close a form to stop it from closing if a date is not filled in.
If the field "Case_Status" is filled in with "response received" and the date field "response_received_date" is blank, it shows a message and fils in the text box with red background.
It simply fails to keep the form from closing till the date is filled in. Code I have so far:
Private Sub CloseForm_Click() If Me.Case_Status = "response received" And IsNull(Me.response_received__date_) Then Me.response_received__date.BackColor = RGB(255, 0, 0) MsgBox ("Please fill in manatory fields!!!") DoCmd.CancelEvent Else DoCmd.Close End If End Sub
I have to write a code in a form so that if nobody is doing any activity for 5 minutes then after 5 minutes automatically press Close button named BtnClose in that form.
I'm sure this is simple, but I can't find it anywhere...
How do I refer to an instance of a form using its key value?
For example, I have a collection 'colForms' and two forms in that collection with the keys 'Key1' and 'Key2'. How do I refer to the instance that has Key1 in code (for exampe, to close or requery the Key1 instance of the form from another form)?
1) i have a table (SQL) "ActiveForm" which contains various fields including a field called "FormName" (Varchar (30)).
2) in the access form called "Menu" i place a treeview control and when i "click" in the node, i read the table rsProcedure="SELECT .* FROM ActiveForm WHERE Active=true";
3) Dim Istanzaform As Integer Dim dbs As Object Dim myFrm As AccessObject rsProcedure.MoveFirst rsProcedure.Find "DescrizioneForm = '" & Node.Text & "'", , adSearchForward
I build the WHERE clause in my form's record source dynamically, depending on the context in which the user opens the form. I can't put the WHERE predicates in the record source and refer to fields on another form, as the context will determine which predicates are required. So I have code like this:
Public gf_FormInstance As Form Dim strSelect as String : Set gf_FormInstance = New Form_F_PerformanceSummary : gf_FormInstance.RecordSource = strSelect gf_FormInstance.Refresh gf_FormInstance.Visible = True
The problem is, the Set statement causes the New form instance to retrieve all records from the existing record source, slowing down the performance.
I'd like to find a trick to suppress the retrieval of records when the Set statement executes, and then allow them to retrieve when the Refresh statement executes.
Yous seem to know virtually everything about access, so hopefully some kind soul could help me out - I think it should be easy enough, but I'm a newbie.
Basically, I have to design a music collection database. I've 5 tables - Artist, Album, Recording Label, Category and Tracks.
What I want to do is essentially create a database similar to the template available on the miscrsoft website. In it, when you go into the Recordings form for example, if the artist if not yet entered (ie cant be selected from the drop-down list), then you can double click and get the Artist form to pop-up. The same goes for Music Category, which also displays a pop-up form if necessary. I'd like to know how to do this??
I apologise if I'm using incorrect terminology, not explaining this correctly, or asking this question for the millionth time, but any help anyone could give would be greatly, greatly appreciated. Thanks in advance.
I am trying to send out data collection emails to fill in my records but it will only let me select fields from single access tables, I want to be able to get them to fill out all the fields as entered in my forms, which contain sub-forms and therefore links to multiple tables.
I have a form that collects data from a survey. The survey has been undertaken before and the equipment being surveyed may carry an ID number and I have the original survey data in a table. If the old survey ID is entered into a field it automatically populates several other fields with the original data....neat!
But that data is not necessarily correct and for this survey I am going to great lengths to ensure the data is as "normalized" as possible so the data is prepopulated into a field with validation. Normally when something is entered into these combo fields I validate with a not in list event and ask if the entry should be added. If I prepopulate with a me.xxxxxx = oldsurveydata the entry is accepted without question. Is there some way to fire the not in list event? I've tried me.repaint, requery etc. but no success.
I have a split form that's like a list of pending tasks. The data source is a linked SharePoint 2013 list where users submit requests. The user takes the information from each record and performs an action. When it is done, the user presses a button and the task status changes from "Pending" to "Processed". The form record source is based on a query that finds only records with a status of "Pending" so when the user changes the status of the task, it is removed from the list. It works fine except when there is only one task left in the work list. If the user processes the last task, the form refreshes and it goes to a new empty record and I get an error message that says I must enter a value into one of the required fields. I tried making the field non-required but it just creates an empty record in the table.
I have a master/child forms. in master form sale_id,collection notes are placed. and in child form all collection details like collectionnumber,date,etc., child form look like datasheet view.
When i select the record from the list depending on the sale_id all the collection records shown in datasheet view form. If no record is there ok. if more than one records are there in collections of sale_id.i need count of records in collection depending on sale_id and also if i select one row in collection, notes to be shown for that record when i clik on shownotes button.
If more than one record in collection automatically it increment. how many collections for the sale_id. collection number would be increment. How and also show notes depending on collection number and sale_id.
I've a custom menu bar from which I can choose any of my forms. However when you choose a new form the old form stays open, sloppy in my mind. Is there any way i can choose the new form from the menu bar & close the previous form? I've tried to close on deactivate, w/ no luck.
I just want to run a series of DoCmd.TransferSpreadsheet commands to export several queries to one Excel Workbook with seperate sheet names for each query.
However my problem is I want this to be a new instance of Excel that the user will then SaveAs after it is complete. I don't want to save it to a specific path first because the Db is on a shared drive and My Documents will have a different path for each user based on their user name. (corporate environment)
There must be some way to just have it open a new workbook without saving isn't there??