Modules & VBA :: Open Filtered Form With Record Source Set
Dec 17, 2013
In my Access adp, when I open a certain form (frmVertebrates), the databinding occurs in the Load event for the form, for various reasons. I have not specified any datasource in the form's design view.
Databinding for frmVertebrates:
Code:
Me.Form.RecordSource = "select * from dbo.vertebrates where catalogID=3"
This works great when just opening the form. However, when opening with a filter from a button on another form it won't work, the form displays all records.
Button code:
DoCmd.OpenForm frmVertebrates, , , "vertID=123"
Obviously, this makes sense, since the record source is explicitly set in the Load event.
Is there a way to capture the filter "vertID=123" so it can be added to the Form.RecordSource sql?
When breaking in the Load-code and watching the 'form' variable, I can't spot the filter condition anywhere...
I'm changing a record source on a form when the user clicks a "save" button.
I'm doing this to store a value from the current form in a table that is not part of the default form query.
This works fine.
I have a separate button on my form called "Home", when the user clicks this button it requerys the current form which triggers the before update event to run, this in turn brings up a message box which asks the user if they want to save or not. If they click yes then it runs the SaveButton click() code.
For some reason when the user presses the save button and then exits, everything works but if a user presses the “home” button which triggers the save button then it brings up the “2107 The Value you entered doesn’t meet the validation rule defined for the field or control.” Runtime error and stops on the change recordsource command.
Why triggering the same code directly from a button or indirectly from a before update event has two different outcomes.
I get the feeling I'm really missing something glaringly obvious here but I'm struggling.....
I have a combo box on my switchboard that looks up field txtOfficer in a query and then want it to open up a new form containing only those records relating to the officer name selectedtxtOfficer
The rowsource for the combo is:
SELECT DISTINCTROW [qryMain].[txtName] FROM [qryMain];
When I select a name from the combo I get a parameter box and have to type in the name to open up the filtered records form. How can I get rid of it so the selection is one seamless process? :confused:
I want to open a report with the results from a filtered form.
I want to use a similar format to the attached Allene Browne search2000 as the base to filter the records initially, but not sure how to get the filtered results into a report and the most efficient way.
I have a form that is opened as hidden when my startup form loads. Data gets entered into it from other forms so whenever I switch records the hidden form needs to be opened to the matching record.
To accomplish this, I have been using the DoCmd.OpenForm in the OnCurrent event with the WHERE clause matching the PK/FK. I have had no luck with the SearchFor method.
It seems silly to have to keep reopening a form to go to a specific record when the form is always open already. Plus, I am wondering if it is affecting the forms' load times.
What I need to do is press a button on a form. When the button is pressed, I want to create a new record in a table not already open and populate some fields with data from the form I am looking at. Then call up a new form with the record I just created on it.
Basically it is a work-order entry issue, the user scrolls through to find the correct piece of equipment when they do they click on "Create work-order" a work order is created and populated and the user can then fine tune the new work-order as required.
i've been working on a sample database today that someone has written some vb code into, which enables the database to merge with some dialler software. basically it's just a hang up and dial button on a form for surveying people.
i've done ok extracting the code for the dial and hangup buttons, referencing the external file and getting my test database to interface with the dialler but it currently allows multiple users to edit the same record, which i need to stop it doing.
the guy that's done the coding says he's more of a vb programmer and not much use in access (he's definitely better than me!) but i should be able to insert some code that will skip to the next record if the record is being worked on with someone else.
i think the piece of code that i need is
Forms("Form1").RecordLocks = 2
the only problem is i don't know what else to type with it or where in the code to insert it.
I've noticed that occasionally when pressing a button I've made to 'create a review record', it will overwrite the very first 'review' in the table even though it should be opening in the form acFormAdd.
I have some code for a button on click event to open a form and select the record which corresponds to a value in an unbound text box. The code is:
Private Sub Command25_Click() On Error GoTo Err_Command25_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmOpenPatientRecord"
[Code] ....
This works fine when I put in a 10 digit NHS number but opens a blank record when I enter a four digit or six character/digit PatientNumber. Both patient number and NHS number are text fields in the underlying table.
I'm constructing a database to record appointments. I want my users to input their appointments on one half of a form (I can manage that bit) but on the other half I want them to be able to see a list of the appointments they already have booked that day (with any patient) or what the patients already have booked that day (with themselves and any other therapists).
The appointment fields they will need to see are:
start time end time patient/therapist (depending on if they are viewing their own or the chosen patients' appointments type of appointment (physiotherapy etc) location
The date won't need to be seen but will dictate which day's appointments are listed.
At it's simplest I could get away with a list of the day's appointments for the patient and date the therapist has typed into the form to start the record.
Ideally I'd like them to be able to choose whether to see a list of the patient's appointments for that day or their own. If there's room I would display both.
Here's the final, 'moon-on-a-stick' bit... it would be great if I could show the appointments in time slots rather than just as a list. From what I can tell that's quite tricky to pull off but i thought I would ask anyway...
At the moment I don't even know what keywords to look up - is this 'embedding a report in a form' or 'inserting a filtered list' and so on.
I'm new to Access and VB but I managed to write parts of what I want access to do.By tweaking a code I found on the internet, I managed to write a small Subroutine that allows the user to click on one of the fields of a record in a report and then Access opens the form on that specific record.*My code goes something like this:*
Code:
Private Sub Edit_Click() * Dim strWhere As String * Dim DocName As String * DocName = "FormName" * strWhere = "[Field Name]='" & Field & "'" * DoCmd.OpenForm DocName, acNormal, , strWhere End Sub
Now I want to get the name of the Table where the record exists.So, let's say when I click on the "Field" it gets the name of the table where the record with that field exists and sets it in a variable.OR even better would be, get the name of the Form where that record exists but I guess that's a little more complicated since the record is directly linked to the table...*
I am receiving the No Current Record message, but have been unable to determine the code that generates it. The database is a system that creates tasks and assigns them to users. In the header section of the Tasks form are several controls they can use to select Active or Completed tasks, refresh the data, sort by columns, etc. There are also three other forms (not subforms) that lay on top of the Tasks form to provide additional detail about the current task.
If they "complete" all their active tasks and click Refresh, all the tasks disappear, as they should, and everything works fine. If they then try to close the form, or click any control in the Tasks header, the No Current Record message pops up. I've put debug stops in every conceivable location, but the message appears to occur before any code is activated.
I did find that I can make the message not occur by commenting out the code that synchronizes one of the associated forms (Notes), but I still don't know what is triggering the message. Debug stops in Notes yield no results either, and clicking a control in the header of Tasks shouldn't affect Notes.
I currently have this set as the forms default recordsource (which works just fine):
Code: SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1
And I have this vba to dynamically switch around that email address.
Code: Private Sub Form_Load() Dim intPos As Integer Dim strControlName As String Dim strValue As String Dim sSQL As String If Len(Me.OpenArgs) > 0 Then ' Position of the pipe
[Code] ....
If I msgbox the sSQL - it shows identical to the default recordsource but I get the error:
The error message I get is:
Run-Time error '2580' The record source 'SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1' specified on this form or report does not exist.
I tried copying the exact working default sql into the vba and get the same result.
I am trying to make use of the OpenForm command to open a form to a record where a textbox matches the value of a text box on another form.
On Form1, I have a textbox called txtRtnRef, and it contains a reference number in a similar format to SWR-9
On Form2, I have a textbox called txtReOrderRef (control source ReOrderRef) which also contains a reference number in the same format (SWR-9)
I am trying to have a button next to the text box on Form1 that has an OnClick Event that opens Form2 to the record containing the same text reference number.I have tried, to no avail, a number of variations of the OpenForm command, the most recent being
I have a main form that has 10 sub forms Each sub forms record source is link to a different Query.
It takes more then a minute to open the form, (because its running the query for all sub forms). So I changed the sub forms source to SELECT * FROM tblTest WHERE false;
I also changed the main form. When the button on the main form is clicked, its adding the following:
Me.SubMySub.Form.RecordSource = "select * from qMyQuery" Me. SubMySub.Form.Requery
However, after I close the main form, the sub forms record source stays linked to SELECT * FROM qMyQuery;
And will take the same long time again to open the main form.
I have Form F_CashSalesHead with a subform F_CashSalesInvFoot with one-2-many relationship on their tables. Subform contains a checkbox field that I use to lock the record set (On a command button click it runs one update query to add value 1 to each checkbox to make Enable=False all the records of current invoice on the form).
One-2-many relation ship is made on InvNum field in both tables.
When I open F_CashSalesHead form, bcz of some code line I wrote on On Load event of F_CashSalesHead , at the beginning it give massage how many invoices are pending to lock and would you like to see. If click Yes to see list, it opens a small form that called F_Count_Unlocked_Invoices showing invoice numbers and unmarked checkbox which is pending to lock. This small form is based on following query,
SELECT DISTINCTROW T_CashSalesInvFoot.InvNum, T_CashSalesInvFoot.CashSalesCustomerName, Sum(T_CashSalesInvFoot.Lock_Cash_Inv) AS [Sum Of Lock_Cash_Inv] FROM T_CashSalesInvFoot GROUP BY T_CashSalesInvFoot.InvNum, T_CashSalesInvFoot.CashSalesCustomerName HAVING (((Sum(T_CashSalesInvFoot.Lock_Cash_Inv))=0));
This works fine.
What I am looking for is, I want to use the same F_Count_Unlocked_Invoices form for Credit Sales invoice also with the same trick. Because I dont want to create another same form and write code that help to increase size of db.
Can it be done just by changing record source of form F_Count_Unlocked_Invoices? Or what is the way to do it?
Heya. I hate posting yet another cascading query but I just poured through the first 40 bits and couldn't find something similar.
Basically, I seem to have an errored idea in how to effectively used cascading boxes on a larger form-wide scale.
Basically I have a form with an unbound combobox in the form header: cboSchool
The detail section should only have two fields, StudentID (txtStudentID) and a boolean (bolOT) both of which exist in a specific table source (tblStudents). StudentID is a locked field.
What I would like to do is only have the StudentID's available that are valid for the school. I attempted using a query in the record source that would reference cboSchool but I keep ending up with blank forms. (There's a string of queries that link the schools found in cboSchools to StudentID)
Hello, I'm having a strange problem and was wondering if anyone can help me out. I have a form that is for inputting and modifying data in one table. It used to work when you opened the form you would see x amount of records. Now it's opening to 1 blank record. If you hit filter it fliters like 1700 records and then when you unclick it, you get the entire 10000 records. I thought it had something to do with the Record Source in the properties but when I fixed that it still didn't work. Any ideas? Thank you!
I have 2 forms. On form1, the record source is a query. From form2, I need to iterate through the recordset from form1 and perform some action. How do I access the recordset from form1?
This code loads a new subform in the frame. It then scopies a value to an input field but then i need to set the record source and display the data. This latest pasrt does not work.I've been trying for some time now by changing the part before recordsource but no luck.
Code: gekozenwo = Me.Keuzelijst0 Forms!switchboard.subfrmWindow.SourceObject = "frmInformation" Dim frm As Form Set frm = Forms!switchboard.subfrmWindow.Form frm.DataEntry = True Forms!switchboard.subfrmWindow.Form!Tekst33 = gekozenwo MsgBox gekozenwo
I have an unbound form with three tabs. On each tab there is a sub form. Each tab is a search form and each sub is a results returned. I have made everything unbound and set the sub form recordsource and its controls control souce on afterupdate of the main form search criteria. Works fine except for after some use the db decides the sub forms are not unbound and sets the record source and control sources.