Change Recordsource Of Subfrm To Another Saved Query OnOpen
Aug 18, 2006
How do i make my subfrm record source switch to another saved query (qryPendingStatus) when it's opened from the form.
Heres what i am trying to accomplish:
I have a subfrm that i'd like to use to display info in 2 different forms.
There's a form currently for All statuses. Then another new one for Pending status. I'd like to use the same subform for this pending status form also, and in doing that my qryAllStatuses, but change to qryPendingStatus on the subfrm when i open the mainfrom.
This is on the open even ofthe mainform, but does not work (says method not founds...so obviouly i can't use ".Recordsource" here:
Private Sub Form_Open(Cancel As Integer)
Me.subfrmJobInfo.RecordSource = "qryPendingStatus"
End Sub
I have a report that can be used for 3 different queries. I've been trying for the last hour or so to get three different buttons on a form to open this report but give it an appropriate record source. I figured there's got to be a way that's easier than three queries, and three reports...? I was trying to use the same format as with forms : [Reports]![rptReportName].recordsource = "qryQueryName"
or variations of that. Am I way off? It keeps saying that I've misspelled the name or it doesn't exist.
I want to write Visual Basic language in the form with one button:
I have one form named "setForm" with one button and one text box: Let's set the new table "frm2", the new form "frm2"
Dim sql As String sql = "SELECT [model].* INTO frm2 FROM [model]" CurrentDb.Execute sql DoCmd.CopyObject CurrentDb.Name, "frm2", acForm, "frm1" Forms!frm2.RecordSource = "frm2"
The last statement code doesn't work: It is said that Microsoft Access cannot find the form "frm2" referred to in a macro expression or visual basic code.
But I don't know what to put for an expression. I would like to use the same form but base the RecordSource on a query called "Receiving Search by Date". :eek:
I have been helped out so many times in the past here I thought I would try my luck again.
Is it possible with the use of option buttons to change the row source of a listbox? I want to use the listbox for a search criteria and thought it might be easier to have 1 listbox been updated from the choices made using a group of buttons. I would like like the row source to be based on different tables maybe I might need to use queries.
the following code saves my report in a folder called test as a pdf file with the name MyReport. I have a string variable called RepName. How can I make the report get saved under that name.
I tried DoCmd.OutputTo acOutputReport, "Estimate", acFormatPDF, "c:Test&MyReport&.pdf" but it dosent work.
I attached a db to better display what I'm attempting to do. How can I get fld1 in subfrm1 (which is in column view) to display the same data in subfrm2 (which is in tabular view)? --
so if I click on the text displaying "dog" in subfrm1, subfrm2 displays "dog" row. If I click on "cat", subfrm2 displays "cat" row?
I am having trouble keeping focus on a field in a subfrm when I click the next button for the next record.
I have a frmQuiz. This shows the quiz question. I have a subfrmUserAnswers, where the user enters the Answer ID in the field UserAnswerID. This form clears to a new record when the Next button is pressed for the next question and the focus is lost.
I have a form that has names with a subform with information. The contacts are in a list box and the subform (in datasheet view) shows the phone number/email/etc.. of the selected contact person. I am using the form as a quick look up of a persons information. Before changing it to a list box, it was previously a combo box, and everything worked fine. i was able to requery the subform and the cooresponding info for the person would come up. However, its now a list box and i am having problems with the code to make this happen. I have a different button sending the names selected from the list box to a report...and that works fine, but i am obvisouly missing something to make it work with the subfrm requery. Below is the code i got so far. Any help would greatly be appreciated. its driving me nuts!
Private Sub QuickLookup_Click() Dim varItem As Variant Dim strWhere As String strWhere = "[memberID] = " For Each varItem In Me.MemberID.ItemsSelected strWhere = strWhere & Me.MemberID.ItemData(varItem) & " OR [memberID] = " Next varItem strWhere = Left(strWhere, Len(strWhere) - 17) DoCmd.Requery "subfrmqryindividual"
I'm trying to create navigation buttons that navigate in alphabetical order. I know that the easiest way to do this is by creating a query and using the query as the recordsource for my navigation buttons, but for the life of me I cannot figure out how to actually change to the recordsource to that query for only that navigation button.
I have a form that pulls data from a big joined RecordSource query. This form needs to be editable. I need to add a field on the form that will contain a value, which is actually the sum of numbers from several records. Because that sum value includes arithmetic in the query itself, I'm assuming that is why the results of the query are not editable. I tried joining the Query that gets that sum value into the main RecordSource statement, but because the sum Query is not editable, doing that renders the whole form uneditable.
I am new to working with Access forms, and VBA in general. I have a lot of experience using VBscript, though. I was asked to get this done and now I have to fight my way through it. I'm hoping there is maybe a way to write a function that will query for the sum value based on the current ID on the Form. The main form cycles through records, and the sum value is a total of points for the record shown in the form. So as each record loads into the form, I need to get the points total that matches that record's ID and display it. The points total does not need to be editable.
Any suggestions for a newbie on how to solve this?
Is there a way to verify the drive that an FE is opening from and then close if it is not where is should be?
I have a frontend that gets copied to each users C: drive by a .bat file. However, some just don't care about rules and proceedures and continue to open the frontend on the network drive. Since they map their drive to a specific letter drive for the BE that is where they are opening the FE from.
Haven't used the 'ondirty' property before and am having trouble with it.
I have a main form (PersAction) with a subform (PersAction_PersData). After Insert button is click, subform appears ready for new data. click save works great. I wish to have an undo button on the main form become visible once data is entered into the subform. I've tried the following code in both the main form and subform 'Ondirty' property as an event and no luck:
If Me!PersAction_PersData.Dirty Then Me!cmdUndo.Enabled = True ' Enable button. Else Me!cmdUndo.Enabled = False ' Disable button. End If
I didn't have this problem when I had used subforms, but there were little bits of thins I had to polish. There are basically 2 tables, and the form is based on the table PKing. It shows the PK and a few irrelevant fields. However, when the recordsource now inner joins the two tables based on the PK, it only turns up 1 record.There are no filters, and nothing is spelled wrong. I checked all of the control sources, and nothing's off. What am I doing wrong?
I have a replicated databse that is used in both 2003 and 2007. Most development is done in 2003. I have stability problems with replicated/synchronised databases when running in 2007. The database normally opens with a switchboard menu, but on occassions the following error occurs:- "THE EXPRESSION ON OPEN YOU ENTERED AS THE EVENT PROPERTY SETTING PRODUCED THE FOLLOWING ERROR: OBJECT OR CLASS DOES NOT SUPPORT SET OF EVENTS". Once this happens the databse will not open. I have to create a new replica which may or may not work. The strange thing is that I can run the database failing in 2007 from another rmachine that is running 2003, so it seems that the problem is specfic running 2007. Any suggestions or help would be appreciated.
Hi I have some drop downs on my form, which has some code that decides which recordsource to use. When I first select an option from the drop down, the query takes 10 seconds to load data. I then select another option, which runs a different query, which takes x seconds. If I then select the original option from the dropdown, the data loads onto the form in less than a second.
Why is there a delay the first time round and not the next? Has Access saved some kind of query plan? If so, why doesn't it save it permanently?
difficult to handle error when executing my report. I put a code into OnOpen section but ACCESS states:
Quote:
The expression OnOpen you entered as the event property produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.
Additionally it says in description:
This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.
I am genuinely confused by that. I have also provided the code in the case if I am missing something I don't know yet. In a debug window, I have executed the code line by line and it worked. Whenever I try to open the report, the error occurs. Should I be aware of something when I write code for reports?
Below, the code in my report "module":
Code: Private Sub Report_Open(Cancel As Integer) Call CreateTempTable End Sub Private Sub CreateTempTable() On Error GoTo ErrorHandler Dim strTable As String
On clicking a button to open a form I want to filter a list in a combo Box located on the forms subform
The main form is called 'Frm_orders' The sub form is called 'sub' The combo box field is called 'CostCodeID' and I want to filter column 0 of the combobox which is Tbl_InvoiceCostCodes.Type to show records with a type of 'Repairs'
I have a multi-select list box that runs a "For intCounter" and builds a sting into a text box. That works fine the text box will populate as designed <"Closed" OR "On-Going">.
(I know that I should be dynamically creating the query in the first place ... normally I would ... but this is a quick fix that I want to get it into an existing application, while the redesign requirements are being written.)
Now I want to pass that string to a pre-existing query, but I'm not sure what to write in the criteria section.
I've tried... Like "*" & [Forms]![ViewReports]![TextPickList] & "*" IIf([Forms]![ViewReports]![TextPickList]="","",[Forms]![ViewReports]![TextPickList])
and just plain old ... [Forms]![ViewReports]![TextPickList]
but my query is coming up blank. What do I need to write into the criteria section of this saved query?
I am using MS Access 2010 to export data into MS Excel 2010 spreadsheets.
I am just wondering: Is there a way to set the Parameter value for the query via VBA?
For example: There are 10 regional managers. When I click a button on a form, 10 sets of data per manager are going to be exported into Excel spreadsheets.
I have created a saved query named [For exporting] with a parameter [Manager Name] for the field [Master Table].[Manager].
The VBA for the button has 2 subs: 1) Sub 1 for the loop for 10 managers
Code: ... strQuery = "SELECT DISTINCT [Master Table].[Manager] FROM [Master Table] WHERE ((([Master Table].[Manager]) Is Not Null));" Set rstStores = CurrentDb.OpenRecordset(strQuery)
My issue is about a saved query which I would like to emulated with VBA.
The whole idea is to update a set of a table's fields based in the status of a control at a form; when the condition is met, the query takes the value of another field for doing the updates.
The original saved query is:
UPDATE EntradaPatiosDetalle SET EntradaPatiosDetalle.precio = IIf([Forms]![EntradaPatios]![patioCheckBox]=True,[precio_patio],[precio_pyme]) WHERE (((EntradaPatiosDetalle.idEntrada)=[Forms]![EntradaPatios]![idEntrada]));
The closest approach I can get to at VBA (which fails ), is:
How can I pass two (2) values to a saved query ? These values are in a form that has a listbox with two (2) columns. The name of the form is 'Previous Evaluation Form'. I'm able to retrieve the values from both columns of the listbox in the form and I've already created the query. Both are working fine, but can figure out how to pass the query's criteria to select records for 'Name' and 'Date' columns of the query. Below is what I had in the 'Criteria:' of the query. What wrong with the code that is placed in the query's 'Criteria:' ?
I have saved query object named qrySearchBill. I wan to call this query through vba and display the result in a subform named subQrySearchBills in datasheet view. Here's how I want it to work:
When the main form loads, I want all unfiltered records to be displayed in the subform initially. The user may then decide to filter based on date range, so he enters startdate and enddate parameter values in their respective textboxes in the main form. Then click search button to run the saved query based on the date range parameter taken from the textboxes.
I have this code so far:
SQL of the saved query object:
Code: PARAMETERS [StartDate] DateTime, [EndDate] DateTime; SELECT tblInvoice.BillNo, tblCrdCustomer.CstName, tblCrdCustomer.CstAddress, tblCrdCustomer.Island, tblInvoice.Date, Sum(tblInvoice.[TotalPrice]) AS Amount FROM tblCrdCustomer INNER JOIN tblInvoice ON tblCrdCustomer.IDNo = tblInvoice.NameID WHERE tblInvoice.Date Between [StartDate] And [EndDate] GROUP BY tblInvoice.BillNo, tblCrdCustomer.CstName, tblCrdCustomer.CstAddress, tblCrdCustomer.Island, tblInvoice.Date;
vba code to call the query and its parameter:
Private Sub btnSearchBill_Click() Dim qdf As DAO.QueryDef Dim rst As DAO.Recordset
Set qdf = CurrentDb.QueryDefs("qrySearchBills")
[Code] ...
This code works fine except that when the main form loads, a prompt window appears to ask for the value of dateStart and dateEnd. I don't want it to prompt because it's suppose to get these values from the main form's textboxes (txtStartDate and txtEndDate respectively), plus it should initially display all the unfiltered records.