Queries :: Retrieve Criteria From Form / When Form Is Closed
Mar 28, 2013
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.
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.
Can I look up and verify data on a "second" form based on a selected record from first (still open) form.
I am trying to allow users to select a User Name from a combo box list and then open "Change Password" form when they select "Change Password" for that selected user name.
My problem is that I can't figure out how to associate and verify the data tied to the user name selected on the previous (Login) form ( I am trying to validate the old password tied to that selected record).
I have the first login form created, and it's working just fine. I also have the change password form created (and it's displaying the user name selected from the first form using:
Code: Private Sub Form_Load() With Forms![frmLogin]![cboUserName] Me.txtPwdChgUserID = .Column(2, .ListIndex) End With EndSub
I also have the code written to validate and confirm old password, new password and validate new password (when the save button is clicked). I have yet to update the password with the new password (still trying to figure that out).
Attached zip file has screen shots of the two forms.
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?
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.
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)
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.
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.
IIf([Forms]![FrmUserSelection]![PricingType]=3,1 Or 2,[Forms]![FrmUserSelection]![PricingType])
My field is Pricing Type and holds records 1 or 2..I would like to pass value from my group option from a form.It works fine if group option has a value 1 or 2 but it displays no records if option value is 3 What is wrong with my code.
I'm trying set the query criteria from a textbox on a form. It's a Status field in the query. 1 = Open, 2 = Closed. If I set the criteria to "1" it shows all open, "2" and it shows all closed and "1" or "2" it shows all. The problem I'm having is setting these in the form. I've set the query to pull the value from the form. I can get the Open or Closed to work but not the All. My textbox shows exactly how the criteria should read "1" or "2" but doesn't show any results.
I've got a continuous form based on a query.Each of the fields have a search box below it (in the footer) which should ideally filter the query.I'm starting with the FirstName field.In the form's query, I've set the criteria to the following for the FirstName field:
Code: Like "*" & [Forms]![frmStudentDetails]![txtSearchFirstName] & "*" frmStudentDetails is the form name. txtSearchFirstName is the search box's name (in the footer). The AfterUpdate event for txtSearchFirstName is:
Code: Me.Requery
But, it doesn't work; when I switch to form view, it displays an error. The Microsoft Access database engine does not recognize '[Forms]![frmStudent Details]![txtSearchFirstName]' as a valid field name or expression.
I am trying to set up a query by form with multiple criteria.For the majority of the criteria I'm using the format: Like [Form]![formName].[txtInputboxName] &"*" .
I copied the Like (...) &"*" from someone else in order to allow for multiple, optional criteria, which does do the trick, however I don't understand why.
I now want to set up a criteria on my query to search for values between two input values to gives the records in the range e.g between 50 and 100 Following the above format, I want to put something that achieves this:
Between Like [Form]![formName].[txtInputboxName1] &"*" AND Like [Form]![formName].[txtInputboxName2] &"*"
with Inputbox1 being 50 and Inputbox2 being 100, however that code doesn't work and I don't know how to get around it as it keeps giving the 'incorrect syntax' error.
WHERE (((Projects.[TeamA])=[Forms]![Search Project by Team]![TeamA]) AND ((Projects.[TeamB])=[Forms]![Search Project by Team]![TeamB]) AND ((Projects.[TeamC ])=[Forms]![Search Project by Team]![TeamC]))