Advanced VBA Wait In Subroutine Until Form Is Closed
Jul 7, 2004
Hi all.
I have a form that opens up another form when you click on a button. The button does more than just open the form, it does other checks. I want to wait until the opened form is closed to continue with the subroutine. Is this even possible in VBA? I was wondering if there was a frmFormName.IsOpen or some kind of flag that would tell me if a form is open or not. Any help would be greatly appreciated. Thanks in advance.
Sub open
Checks things
Checks things
checks things
Opens form(frmDetails)
Wait for form to close (THING I DON'T KNOW HOW TO DO IF POSSIBLE)
Is there anyway to have a subroutine be called when a form is brought up? meaning, as soon as the user opens the form, stuff happens without them doing anything besides opening the form.
Evening All! (Old enough to remember Dixon of Dock Green (stupid enough to mention it!))
I'm working on a small database for a small team of support workers with a client base of 60 clients at anyone time, although the turnover is quite substantial.
I have done some searches on archiving records but am concerned that once archived a record would be difficult to re-integrate in to the live database, particularly if there have been changes to it?
I have considered that I may be just as well slapping a big label over every record that has a date in the [CloseDate] field and if a closed case is re-opened, the closed date is removed and the label disappears.
I'm still open to being convinced that the archiving is the way to go, but in the mean time I hope someone will be able to help with the expression needed in the form on_current procedure to make the label visible. If it was just a tick box I'd be flying by now, but I can't get my head around getting a populated [CloseDate] field to initiate the CloseRecordLabel.
Please help me if you can. We are in a state of panic right now in trying to figure this out and any help would be appreciated.
Basically I have tried many different angles and have not come up with a solution that works. I have spent 80+ hours trying to figure this out with no luck.
Here is what we need to do: We have a database that has data that needs to be printed on a 3"x6" sized tag. Now there are probably 5 or so different tags that need to be printed. What we need to happen is be able to provide a way to print out all the tags at the same time. The problem is I cannot seem to create one report that will generate all the tags correctly (I could create the code to do this in a form, but I can't get it to work in a report), and I don't know how I would combine multiple reports so that all the tags can be printed at once.
Do you have any ideas on how I can do something like this?
I'm creating an advanced search form which is making use of Like queries and is Null. A working example is below:
Like "*" & [Forms]![Frm_Data_Mine]![Combo_Primary_SIC] & "*" Or Is Null
So this either returns matching values from the field, or basically ignores this if left blank. All good.
I have two other fields:
[Turnover_From] [Turnover_To]
Both are numeric values. What I would like to achieve is the same as the above, so I can search between a from and to value, or if left null, ignore them. I had a go with the below but it's clearly not right, and I can work how where and how I insert the Like statement which makes the others work.
Between [forms]![Frm_Data_Mine]![Turnover_From] And [forms]![Frm_Data_Mine]![Turnover_From] Or Is Null
I have a series of forms that become current in a certain order. For example a menu form comes up. This is followed by a search form where the user gives search parameters. Then appears the results list. If the user wants a detail form comes after that, etc. Now when the user closes the last form I want the form before that one to show up and when he closes that one the one before that and so on. That is I am going to use the close button to go back to the previous step. How can I do this.
I am stumped as to how to get a form to update/refresh. Heres what I have! My main form:[Daily Log From] is opened, with a subform:[DailyDSQry subform] populated by a Query. This form has a command button that opens another form: [NewDSLog] in "acAdd","acDialog". What I need is: when the [NewDSLog] form closes, the [DailyDSQry Subform] needs to requery/update so that it displays the new entry.
I have tried the following in a command "CLOSE" button in form [NewDSLog]: docmd.Runcommand AcCmdRecordSave Me!Forms![Daily Log]![DailyDSQry subform].Refesh Me!Forms![DailyDSQry subform].[Query].!Requery doCmd.close
but no LUCK.....Keep getting errors Any Ideas Thanks all, I do appreciate the help Enviva
I have a DB with 20 forms. All of the forms are closed. I opened a new form and added a button. I would like to do the following when the button is clicked:
Check the "Tag" property of each form and count whichever is not null.
I have a form which is associated with a table. When I put some values in the fields which are connected to the database and try to close the form, it gives me an error that "Can't insert record the primary key might be duplicated"...! and then it closes.
Does the form store a record in the table while closing??
If so is there a way to prevent it?? Please reply..
I would like to have the Switchboard I created open when the database is selected. I used Tools/Startup to set this up. It works to a point. The database window opens and THEN the Switchboard opens (on top of the database window). There are some who I wish not to see the database navigation window). Also, is it possible to OPEN the switchboard again when a Form is closed?
I have a query that retrieves one of its criteria from a form. I have referenced correctly the value on the form from the query, and it works, but what I wanted to do is a bit more complicated: when the form is closed, I want to launch the query with a "default value". I tried to do it in 2 different ways:
a) Defining an "IIf" at the query criteria: I would need a function that checks if the form from which I retrieve the values is open. b) Defining public variables with a default value, which would be changed from the form: I don't know where/when to initialize the value of the variable.
Query gets criteria from form when it's open. If form is closed, query uses default value.
Hi, I have code for a command button that allows me to save the form information to 7 different tables primary key (the same primary key), owever when i close the form it resaves the information and i get a duplicate error msg. Is there anyway to get around this? Can I change what happens when the form is closed. i tried to apply this code to Form_Close() but to no avail.
I am running Access 2010. I am building a form that is finding the "Docket Numbers" from three different forms. In order to get these numbers, I put in three text boxes with these statements:
Text box1 =[Forms]![Jobslist]![Docketnumber]
Text box2 =[Forms]![Jobslist2]![Docketnumber]
Text box3 =[Forms]![Jobslist3]![Docketnumber]
However, not all three forms will necessarily be open at one time so I am trying to use an Iif statement to check if the form is open. I can't seem to figure out the function to check if the form is open. I am looking for something along these lines:
Text box1 =iif([Forms]![Jobslist] = closed,"",[Forms]![Jobslist]![Docketnumber]
What i need to figure out is what to used instead of "= closed".
I am wondering whether it is possible to trigger the run of a macro when a form window is closed using the close button in the top right of a standard window?
If not, then is it possible to display a form in a window without the minimize, restore and close buttons?
I am currently using a setup whereby I have a button to close a form, and when clicked a macro is executed. However, the user could just as easily close the form using the close button of the window and the updates would not be performed.
I have a main form called frmAF54. In this main form I have a subform named frmPassdown. The subform record source is from a table called tblCards. This table contains many different cards. I have a combobox called lstOpCard in the main form as well. The combobox lists all of the different cards in "tblCards". I have a button called "buttonFilter".
A user opens the form and clicks (or selects) the different cards in the combo box "lstOpCard" that they want to filter for. Once their selections are made, they can click the "buttonFilter" button and the subform "frmPassdown" will be filtered based off of their selections.
The filter is applied using the IN() function as shown below: Me.AF54PassDown.Form.Filter = "[OpCardID] IN ( " & sTemp & " )" --sTemp is a string containing the keyIDs of the cards selected.
My problem is that people will be opening and closing the form throughout the day / week. When the form closes, it loses the applied filter. How can I have my filter on the subform be saved after the form is closed and the filter is still applied when the form is opened later?
I have a form for which the Record Source is a certain table. Then on that form there is a button to display another form, which adds a new record to the same table. Then the new form is closed.The trouble is, the original form cannot search for the new record, until you close the form and reopen it.I have tried using Me.Dirty is false, and also a requery of the original form, but nothing works. Only closing the form and reopening it will display the newly added record.What can I do to make the original form recognize the newly added record?
There is a form where whenever the form is closed, the below code needs to execute:
If IsNull(Me.CostPerPiece1.Value) = True And IsNull(Me.CostPerPiece2.Value) = True And IsNull(Me.CostPerPiece3.Value) = True And IsNull(Me.CostPerPiece4.Value) = True And IsNull(Me.CostPerPiece5.Value) = True Then Me.AllowAdditions = False DoCmd.SetWarnings (0) DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings (-1) Else Call AppendQuoteCharges End If
The If Then just looks at if certain fields are all null and if so, it deletes the current record. If at least one field is not null, the AppendQuoteCharges routine is called.
The form has 4 or 5 navigation buttons that close this form and send you to a different one. I've added the above code to each of those buttons before it runs the DoCmd.Close Form. I also have a Exit button that runs a DoCmd.Quit. I developed this months back but I'm pretty sure I added the above code under each button's click event rather than a Form On Close event because Form On Close does not execute after a DoCmd.Quit command
In rare cases, the form is being closed without the routine being ran. I think if a user clicks the Close button in the top right of Access (the X), it might be running a DoCmd.Quit which is doesn't run this code.
How can I be sure that whenever the form is closed or exited, the code is ran? Is there a way to tie this code to the user clicking the X in the top right?
Hi Ive been searching for answers need assist. I have a multi tab form with multiple sub forms and control buttons. One of the buttons calls a report to come into preview mode.
the problem is when I close the report the multitab form loses its max size. I have tried docmd.maximize on the on open, on got focus of the form and I have tried the docmd.restore as well with no luck.
Hi Ive been searching for answers need assist. I have a multi tab form with multiple sub forms and control buttons. One of the buttons calls a report to come into preview mode.
the problem is when I close the report the multitab form loses its max size. I have tried docmd.maximize on the on open, on got focus of the form and I have tried the docmd.restore as well with no luck.
I'm using hte Shell() function but this doesn't wait for the executable file to finish so I'm looking for a command line function that would wait until the executable file is finished executing...
I saw this function WaitFor but it is not supported in MS-Access? So, what do I do?