Forms :: OnLoad Runs When Closing Form
Oct 9, 2013
I have an A2007 application running on XP. From main form, Form1, another form, Form2, is opened.
When I attempt to close the application by clicking in the cross in the rh-corner of Access window, I get a crash midway through the OnLoad of Form2. I cannot figure out why the heck the On Load event fires when the form is being closed, and have some difficulties stepping through the code.
I recall having heard of OnLoad firing when trying to close a Form.
View Replies
ADVERTISEMENT
Apr 15, 2013
I have some code on a button that opens a form and changes the caption of a label:
Code:
DoCmd.OpenForm "frmRepair", , , , , , "CancelNo"
Forms![frmRepair].Form.[lblmain].Caption = "Missing Parts"
This code works well and frmRepair opens with the updated label caption. The original value was "Return/repair Information"
A few other things need to change on frmRepair depending on this caption as well as the values of some other fields, so I use the following code in the onload event (although I later tried the onopen even)
Code:
'Disable labels button if there is no RMA and the item is a repair
MsgBox Me.lblmain.Caption
If Me.lblmain.Caption = "Return/Repair Information" Then
Me.txtRMA.SetFocus
MsgBox Me.txtRMA.Text
[Code] ....
However, I cannot get this to work as the "if" statement always returns "Return/Repair information" and not the modified caption. The message box confirms that this is the case.
I suspect that this has to do with the point in time that the frmRepair loads or opens and when my code enters the modified values.
View 13 Replies
View Related
May 27, 2013
is it possible to create a form that runs only once when db first run for name etc. And then once saved cannot be changed by end user.
The last bit I can do its just the making it run once as a popup.
View 13 Replies
View Related
Mar 17, 2014
I have a userform that pops up when I am implementing a VBA subroutine. The nature of the form is simply to update the user what progress through the operation the code is using a label called lblProgressText.
So, I have a form called frmProgress and in my loop I use:
Code:
DoEvents
Form_frmProgress.lblProgressText.Caption = Format(rsLongItems.PercentPosition / 100, "0.00%") & " - Long items"
Form_frmProgress.pbProgressBar = rsLongItems.PercentPosition
Form_frmProgress.Requery
Form_frmProgress.Refresh
Form_frmProgress.Repaint
I know I don't need the .requery, .repaint and .refresh lines but I put in there just to check it wasn't that causing the issue.
When my code runs, the form is opened using:
Code:
Form_frmProgress.Modal = False
DoCmd.OpenForm Form_frmProgress.Name, acNormal, , , , acWindowNormal
The form Popup property is set to Yes.
The lblProgressText control just wont update (but earlier today it was so maybe I have broken something).Btw, all this code is run from a Module, not in the form object.
View 3 Replies
View Related
Dec 24, 2014
I have created a form with buttons which runs queries. The parameters I need for the query are being passed through just as I wish and the relevant query is run correctly. However, if I then press the button on the form with different parameters I get the results from the previous query. I can only solve this by closing the query before pressing the button. Is there an easy way to close the query to prevent this from happening. In case this is relevant, the only data which I am returning from the query is stored in the windows clipboard.
View 6 Replies
View Related
Jul 8, 2014
I have a form with a subform. There is a close button on the main form which I have applied a key command of Alt + c and when the focus is on the main form it closes the form as you expect. But if the focus is on the subform, using Alt+c does nothing. I am trying to give the user a way to avoid using the mouse (so they do not have to click on the button from the subform. Also it is confusing that the key command doesn't always work in the view of the user, and in reality he is on the subform.)
So my thinking is:
1. Can I create a close button on the subform (and give it the key command of Alt + c) and in the code close the form and subform, if so - how to I refer to the form/subform?
2. Is there some way to apply the key command of Alt + c on the subform to activate the close button on the main form?
View 4 Replies
View Related
Mar 14, 2013
I am using Access 2010 - Version 14.0.61.29.5000 (32-bit)
I am building a custom Export Wizard to export data to Excel using the Report Wizard for the basic ideas.
All I am trying to do is have a [Back] button on a form to open another form and close the current form.
Private Sub cmdBack_Click()
DoCmd.OpenForm "frm_ExportWizardPage2", , , , , , Nz(Me.OpenArgs)
DoCmd.Close acForm, "frm_ExportWizardPage3"
End Sub
The new form is opening but then the current form is not closing. All forms are the same size, shape and positioned centrally although this should not make any difference.
Could this be anything to do with which form has the focus when I open the new form?
View 2 Replies
View Related
Aug 16, 2015
I have a form with an onload event that apparently only runs when it wants to. I've checked the onload property on the form and it is set to event procedure. Went through the code on the event and everything looks good. When i mark it in break mode and step through it it runs fine. When I take the marks off it sometimes works and sometimes doesn't.
View 6 Replies
View Related
Feb 4, 2014
I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.
When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).
Is there a way to trap Data on form just before the form closes?
View 4 Replies
View Related
Jul 9, 2013
I have a form (frmAuditEntry) that includes a subform (sfrmAuditDetail). The user will enter audit information on the subform. There is a check box on the subform to identify containers that had errors in selection. When the box is check by the user, a pop up form opens where the user can enter the details regarding the type of error. The audit number and the container ID are carried over from the main form to the pop up form to link the information.
This is the code I have in the AfterUpdate event of the checkbox:
Private Sub Errors_AfterUpdate()
Dim rs As Object
Dim strBookmark As String
strBookmark = Me.ContainerID
Me.Requery
[Code] ....
This works great and keeps the focus on the record the user checked having errors so the right information transfers tot he pop up form fields. When the pop up form is closed, the focus goes back to the subform but keeps the focus on the container ID control of the record that the user previously checked as having errors (hope that makes sense).
What I would like to happen is this: When the pop up form is closed, I want the focus to go back to the subform but to go to the last blank record on the subform (if the user moved off the record before checking the error checkbox) or go to a new record (if the user did not move to a new record already before checking the error checkbox).
View 1 Replies
View Related
Apr 14, 2014
I have two ways to enter work placements for students, I need to refresh a subform on one form while closing another.
The issue here is the form with the subform may not be open as mentioned above.
So is it possible on closing one form to refresh a subform only if it's parent form is currently open?
View 1 Replies
View Related
May 26, 2015
The image below describes the scope of the issue.
The function is called upon in the onLoad event of frmMain.
View 3 Replies
View Related
Jun 15, 2014
I have a popup called by a subform to add a new record or edit a selected record. I keep getting "Runtime error 32502". The value you entered isn't valid for the field "|"
I have no required fields and all the drop down related fields have the right value type in them (That I can find)The only "|" reference I can find is in the OpenArgs content below when I load the form. If I'm adding a new record I pass two fileds via the OpenArgs
Private Sub Command52_Click()
DoCmd.OpenForm "AddDebtorPaymentFrm", , , , acFormAdd, OpenArgs:=Me![DebtorId] & "|" & Me![MatterId]
End Sub
or if I'm modifying a record from the subform on click I
Private Sub Text38_Click()
DoCmd.OpenForm "AddDebtorPaymentFrm", acNormal, , "[Transactions].[TransId] = " & Me.TransId, acFormEdit
End Sub
Below is the Popup Load code
Private Sub Form_Load()
If Me.DataEntry = True Then
Me.VariableHeading = "Add A Debtor Payment"
[code]....
View 8 Replies
View Related
Sep 12, 2013
I have a search form (Form1) that sends the results to another form (Form2) using OpenArgs.
When Form2 opens with the filtered records, it may display 1 or more records (for example, the order number searched for in Form1, the customer may have bought 2 items)
So with my 2 records displayed in my continuous Form2, I have included a bound check box that can be checked by a sales team member of staff if we need to send a replacement item(s).
If the sales person has started the process and checked the box for both records but decides to close the form instead of reordering the goods for the customer (hometime) and decides to Close Form2.
How do I program Access to uncheck both boxes so the table is not updated with the check for each of the items, as this will start a chain reaction and the goods will get packed and shipped. It currently just unchecks the first record if I include Me.ItemSelectedResend = False in the Close form vba code.
I thought about just including a message box on the screen prompting the user to uncheck the boxes before closing, but surely there must be an automatic way in which I can do it.
View 1 Replies
View Related
Apr 11, 2014
Below is some code that I'm struggling with and I get an error message "Type Mismatch".
Description: The database contains multiple projects and the subset of each project is a release. The "PublishedNumber" can't be a duplicate within a release, but it can be a duplicate within the table where the data is stored. There can however be multiple occurrences of 0.
Here's my code:
Dim stLinkCriteriaRelease As String
Dim stLinkPublishedNumber As String
Dim DuplicateNumber As Variant
stLinkCriteriaRelease = "[AssociatedRelease]=" & [AssociatedRelease]
stLinkPublishedNumber = "[PublishedNumber]=" & [PublishedNumber]
[Code] ....
View 3 Replies
View Related
May 8, 2013
On a pop up form I have a list box. The row source for the list box is
Code:
SELECT tblWebOrder.WebOrderId AS [Web Order No], tblWebOrder.CustomerWebOrderNumber, Format([WebOrderDate],"dd/mm/yyyy") AS [Order Date], tblCustomer.CustomerName AS [Customer Name], tblArea.Area FROM (tblCustomer LEFT JOIN tblArea ON tblCustomer.[PhysicalAreaId] = tblArea.[AreaId]) INNER JOIN tblWebOrder ON tblCustomer.CustomerID = tblWebOrder.CustomerId WHERE (((tblWebOrder.Processed) Like [Forms]![frmSelectWebOrderToOpen]![txtOrderStatus]) AND ((tblWebOrder.WebOrderDate) Between [Forms]![frmSelectWebOrderToOpen]![dteStartDate] And [Forms]![frmSelectWebOrderToOpen]![dteEndDate]+1)) ORDER BY tblWebOrder.WebOrderId DESC;
I have the following "On Click"event on the list box
Code:
Private Sub lstWebOrder_Click()
lngWebOrderId = Me.lstWebOrder.Column(0)
DoCmd.Echo False
DoCmd.Close
DoCmd.Echo True
End Sub
When I click on some of the records on the list box the form closes. On some of the records I get a parameter prompt to enter:
Forms!frmSelectWebOrderToOpen!txtOrderStatus
Forms!frmSelectWebOrderToOpen!dteStartDate
Forms!frmSelectWebOrderToOpen!dteEndDate
I inserted the echo commands to prevent this, but this has not worked!
Why am I getting the prompts? How do I prevent them?
View 4 Replies
View Related
Jan 2, 2008
Alright. I've tried searching, but to be honest, I'm not even sure what to search for.
I want to create some VBA that onLoad of the opening form of the database, it will take info from a query that looks for data entered for a student. It will be looking to see if there is data in two date fields. If it finds data in both fields, then I want to make a change to the EnrollmentID row of another table to changed the graduated column from No to Yes.
To expand on that, I'll want to check each ClassID row and if all of the associated students of that class have the column Graduated checked as yes, it will place the date in the date column for that particular class.
This is essentially my way of auto-archiving data as the combo box selections on my forms don't allow for class data to be shown if there is a Closed Date entered for the class and you won't be able to enter more test results for a student if the Graduated Column is checked in the Enrollment table (associates memberID, ClassID, CourseID into a single table)
Any insight on how to do this would be greatly apprecaited.
View 6 Replies
View Related
Sep 26, 2014
I currently use code in a module and code on each form in the on_load event to change the icon of the form.. the code i use is as follows..
in a module:
Code:
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const WM_SETICON = &H80
Private Const IMAGE_ICON = 1
Private Const LR_LOADFROMFILE = &H10
Private Const SM_CXSMICON As Long = 49
Private Const SM_CYSMICON As Long = 50
[Code] ....
And on each form on load:
Code:
SetFormIcon Me.hWnd, "k: est directoryhsicon.ico"
What I am wondering is would it be possible to store the .ico file within the DB file itself (i know access can store bitmaps) and reference the .ico in the form load event code?
Overtime the db file will probably move to its own dedicated storage so using a direct reference to the file wont work..
I have tried the following but get an error (it tries to reference the .ico file as to being in the root directory of the db file)
Code:
SetFormIcon Me.hWnd, Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "hsicon.ico"
View 2 Replies
View Related
Aug 5, 2015
I have a "Search" form that I am using to search through a query in a list box of all of my Customers. Once the record that I am wanting to view comes up I highlight it and click a "View" button to bring up another form with the customers full record. When this form is open I am able to update the customer information and add User's to it if necessary.
My problem comes after I click on my save and close button that takes me back to me search form. I want to close the search form and the error I get is "The record cannot be deleted or changed because table "tblUserProfile" includes related records." I click OK and get a SECOND error stating "You can't save this record at this time. MS Access may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"
I have already made my changes and saved them in the form with the customer record so am not sure why I am getting an error when trying to close the Search form.
View 5 Replies
View Related
Jan 26, 2007
I have a form set up and would like to have field update to a table when a policy number is input into the form. The fields are extracted from a linked table and are not viewed on the form but need to be written to a table to create a report. I'm confused on the sets to take to handle this. I think i need to use the "onchange" property and set up a macro that runs a query but how does the query write to the table?
View 1 Replies
View Related
Apr 7, 2014
I have a Form opening from Access Options. I would like to close this Form using the Timer. The following is the code I have used but it is not working.
Private Sub Cover_Page_Form_Load()
OpenTimer = Timer
End Sub
Private Sub Cover_Page_Form_Timer()
If (Timer - OpenTime) = 5 Then DoCmd.Close acForm, "Cover_Page_Form", acSaveYes
End Sub
Next question. If I can get this to work can I then use a DoCmd to open new Form within the code above or do I need a new process.
View 5 Replies
View Related
Dec 31, 2004
Does anyone know a line of code I could write that would close all other forms, besides the form the user is working on?
I can't stand it when a new form opens up and the old one is still open. I have written individual macros to close the forms, but that is getting rather cumbersome. Any help is greatly appreciated. Thanks!
View 3 Replies
View Related
Jul 14, 2015
I have had some issues caused by users exiting the database entirely when they realise that they have entered something incorrectly; this in turn has caused problems re-opening the half finished record (the last step of the record creation is to allocate it a unique reference number, which is then used to re-open the record for editing on a point and click form) - now, this is entirely my fault for expecting users to clear up behind them or to exit properly.
So, I am making some changes - when the dashboard form opens it removes the database window close button. I have a separate close button which has the following code:
Code:
Private Sub cmdGoodbye_Click()
Do While Forms.Count > 0
DoCmd.CLOSE acForm, Forms(0).Name, acSaveNo
Loop
DoCmd.Quit
End Sub
However, I would like to add a line to automatically save any records before closing each form - is this possible?
View 7 Replies
View Related
Sep 15, 2005
I have an unbound start-up form with a button that I want to open another form. When the user is done with the second form and clicks a close button, I want to bring up the first form.
Q. Is it best to leave the first form open in the background or close and re-open it? (And why?) :confused:
View 2 Replies
View Related
Aug 31, 2006
To try to keep a sane user interface I would like to close forms as another form opens.
If I put a Command button on FormA that opens FormB and it is set to find a record on FormB ... how can I close FormA when FormB opens.
I tried putting DoCmd.Close either before and after the code that opens FormB and ...
If I put it before the code - it just closes FormA without opening FormB ... if I put it after the code, if opens FormB and closes it.
Is there a way of saying on a form 'close the form that just opened me'? (like in javascript where you can reference the form with window.opener)
Thanks for any help.
View 4 Replies
View Related
Sep 11, 2014
I have a form which opens as a pop up when the system starts. On here are several buttons, which open other forms.Some of these just open another form and the user starts using the system, other close that form and open another one, and take go further into the structure of the system, then the forms that open have the same etc.For each of the buttons the code is very similar..For forms that open another one and don't close the main form:
Code:
Private Sub cmdescalations_Click()
DoCmd.OpenForm "frmEscalations"
End Sub
for those that close the form:
Code:
Private Sub cmdStock_Click()
DoCmd.Close acForm, Me.Name, acSaveNo
DoCmd.OpenForm "frmMain_Stock"
End Sub
Just the main of the form it opens changes, and sometimes with ,,,dialog in the options if its required.The opening part works every time without fail, but the form doesn't always close and I end up with two forms open instead of one. If I close the newly opened one and press the button again it works fine. This is purely random and only started a few days ago, up until then it has been working fine.
There is a hidden form that is open as well when the system starts, which check for something on a timer event every 60 seconds. If that event is firing would the focus shift to the hidden form, between me pressing the button and the event firing and the hidden form is getting closed? then the new form opening?
View 2 Replies
View Related