Using OpenForm Macro To Open A Subform To A Specific Record
Aug 24, 2006
Hello, fantastic site you have here!
I have a form based on a table called TermWithPaysStoredData that shows a single row for everyone in the table with a small amount of info from the table and has controls for a user to enter dates which writes to that same table.
I have a subform that reads that same table but has much more information about each row. I would like to add a button to each row of the main form that says "More Info". When clicked, it should open the subform to the same employee.
The field I want to match is called ID. My main form is called fTermWithPays and my subform is called fTermWithPaysMoreInformation.
I tried using the OpenForm method but that either opens the form to the first record or filters and shows only one blank record.
I'd like to use a macro for this if possible because I don't know VB.
Any ideas? Let me know if more explanation is needed.
I'm very new to access database and I'm trying to create a macro that allows the user to enter data after seeing a mistake in a form. I need a macro that will open the specific table and record of a piece of data. For example there is a student TestName3 whose grade on a competency is 30% but should really be 45%. I want a macro by the competency percentage to allow the teacher to edit that without looking through the entire table. The macro should prompt first to ask if the teacher is sure they would like to edit, second prompt asking for the student's unique ID number, and finally be taken to the specific record and table related to that competency.
I have tried to use a vastly overcomplicated DLookup and Order column to give me the value for a acGoTo search.
Here's what I have.
Option Compare Database
Dim answer As String Dim response As Object Dim gotoresponse As Object
Private Sub Command71_Click() On Error GoTo Command71_Click_Err
I am not a specialist, but am trying to create an application with Access 2000to manage our company’s orders. I have a table called ‘Service’ containing descriptive data on the type of service requested. This table is linked to several other tables, with ‘ServiceNo’ as the primary key linking most of them. The service number is not an autonumber, but a counter incremented through code, for specific reasons that I won’t develop here.
I have created two forms: one to consult all the service records (F_Service_Consult), with a button to open another form that allows the user to add a new service record (F_Service_Add).
When the new service form opens, the service number counter is incremented and this number is assigned as the new 'ServiceNo' in a new record added to the ‘Service’ table (using the SQL ‘Insert’ command). I would like this form (F_Service_Add) to open on this record only. In the code that creates ‘ServiceNo’, the correct value is contained in a variable called ‘lngServiceCount’. I have tried using this code to open my form:
Dim stDocName As String Dim stLinkCriteria As String stDocName = "F_Service_Add" stLinkCriteria = "Forms![F_Service_Add]![ServiceNo]='" & lngServiceCount & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria
When I run the code step-by-step, the correct value is shown for ‘lngServiceCount’ when the mouse hovers over the variable (for ex. ‘155’). When the form opens, I have 1 record (Filtered), but nothing shows in the ‘ServiceNo’ text box.
I have deactivated the code that is in the ‘OnCurrent’ event procedure of this form to avoid any interference.
There are many sub-forms on the main form, which also contain the ‘ServiceNo’ in text boxes.
When I use this command to open the form:
DoCmd.GoToRecord , , acLast
the form opens correctly, with the correct ‘ServiceNo’, but ALL the records are opened.
The variable type for ‘lngServiceCount’ is a long integer. (I hope that is the correct term in English, because I am using a French version of Access).
I would be very grateful if anyone could tell me what I’m doing wrong. I’ve tried to be clear, but if more information is required, I would of course provide what’s missing. Thanks in advance.
I am trying to open a single form with a single subform with a command button. I would like to open the form with the subform on a specific record but I am not entirely sure how to do this, I was wondering if someone had any advice that could help.
I really hate being stupid about this, but I'm running around in a circle and it's making me dizzy. All I want is a simple macro that opens a form (with a subform) at a new record from a button. I know I am missing something obvious so I will let others see if they can find out what has gone wrong. The current macro is:
On the property sheet of the form the following are all set to yes: Allow Filters, Allow Edits, Allow Deletions, Allow Additions, Data Entry (I suspect the problem is here) Record Locks is set to No Locks.
When I open the form from the button, it looks right, and I can enter the transaction information, but when I try to enter the subform information or save it , I get "The Microsoft Jet database engine cannot find a record in the table 'NewContacts_tbl' with key matching field(s) 'ContactID'". I get the same message with Allow Data Entry set to no.
And yes the key field IS there, in spite of what the Microsoft Jet database says.
I hope everyone gets a chance to enjoy the holidays and thanks to all of you for your past help and my current (relative) sanity.
I have a parent form showing some of the contents of a single record in a parent table. This form contains a button that opens a specific subform (using an IF statement based on the contents of another field in the parent table/form. There are actually any of 8 child forms/tables that could be selected and the related record is in only one of them. The relation between the tables is based on the PK of the parent table and the related FK in the child table. and the data is correct in all tables.
My problem is that when I run this button on the parent form/table it returns the appropriate form/table, but displays the first record rather than the related record. In the past (using this same process) I have been successful in getting to the right record by fiddling with the where statement (sometimes putting in a equal sign or taking it out fixes the problem). However, no matter what I do to the Where statement nothing works. I have not yet placed the final else condition for where the form selection field (VMValIdentType] is empty yet as there is no point at this time.
Here are the button macro contents:
If [VMValIdentType] = "Software" OpenForm Form Name: tmpVMValSW View: Form Filter Name:
Basically I have a database that records commitments for clients. The user can go a client form, and within that form there is a subform which shows each expenditure commitment for that person (wihtin the subform there is also another subform that shows all income attached to each commitment). The user can use the Next and Previous buttons to navigate through the expenditure commitments (and the same if they want to navigate through the income commtiments within each expenditure commitment).
If you double click on any specific commitment whithin any part of the subform, then the expenditure commitment form (or the income commitment form if it is an income one) opens to allow the user to change stuff.
My database is set up so that each time a form opens the previous form closes. So when the user has the commitment form open and clicks close, the client form will re-open. My issue is that is always goes back to showing the very first commitment and the user then has to navigate back through till they find the one they have just updated.
What I would like to be able to do is when the user closes the commitment for that the client then the form opens up with the specific subform on the screen that they have just changed.The code I currently have written on the Close command of the Commitment is as follows:
Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmTotalCommitmentsbyClient stLinkCriteria = "[FrameworkID]='" & Me![FrameworkID] & "'" DoCmd.OpenForm stDocName, , , stLinkCriteria DoCmd.Close acForm, "frmCommitments"
I essentialy just need the bit that would also say show the subform (which is called subfrmComms2) where the commitmentID = the commitment ID on the Commitment form.Now just to really complicate matters, I would also like this to happen if someone has the Income Commtiment form open and they close it, only the Income Commitment subform is actualy a subform of subfrmComms2 (above), but equally the income commitment form has within it the Expenditure ID, the Income ID and the FrameworkID.
I've got a form with a subform on it that has a subform on it (nested subforms - Customers form with computers subform, which has a software licenses subform on it)
I'm trying to put a button on the top-level customers form that will jump to a new record in the software license subform-subform (the licenses form is displayed as continuous with a blank at the end for new license entry). I want to set the OnClick action to move the record selector on the software licenses subform to the last (new) record in the continuous form display. I can't figure out the appropriate path to use as the Form Name in my GotoRecord macro.
Is there a special trick to use when referencing subform controls?
I am trying to use the double click event of a listbox to open a form to a specific record. The problem I have is when I double click a record, Access pops up a box asking for PONumber (which is in column 0 of the listbox).
Here is the code that I am using:
Private Sub lstPOInfo_DblClick(Cancel As Integer)
Dim boStatus As Boolean Dim strDocName As String Dim strLinkCriteria As String
strDocName = "Orders"
' function checks to see if the form is open or not boStatus = fIsLoaded(strDocName)
If boStatus = True Then strLinkCriteria = "[PONumber]=" & Me.lstPOInfo.Column(0)
Is it possible to use VBA or macros to open a table to a specific record?
I know how to open a table in database view using a command button. I'd like to have it open to or automatically scroll to and select a specific record, based on the content of the form. This way I don't have to spend time scrolling through the whole table to try and find the desired record.
Need to open a form to a specific record.Ive done the command button wizard that opens the form to a specific record but but that brings up the form with the filtered button showing.I've tried to put the formula into the filtered section but that doesn't work.I just want to be able to open the form to the specif record and then be able to navigate to other records if required (without aving to press the filtered button)
Currently, I have a form with tabbed pages in it. The second tab, I have a subform inserted into it. I have a completely separate form that looks through records. I want to be able to click on a record from the separate form and open the Main tabbed form, to the second tabbed page, to a specific record. Currently I have:
Private Sub Form_DblClick(Cancel As Integer) Dim stDocName As String Dim stLinkCriteria As String stDocName = "frm_Main_Data_Entry" DoCmd.OpenForm stDocName, , , stLinkCriteria Forms![frm_Main_Data_Entry]![pgAgreement].SetFocus End Sub
Which opens up to the tabbed page just fine. but I can not figure out how to get to a specific record.
Also, the subform in the tabbed page, doesn't have the same controls as the Main tabbed Form itself, so when I add something like:
I want to ask what is the code for Macro Builder in a command button if I want to open a report from the given value of inputbox. I made a command button to open a report but it will ask first the required value from inputbox I put. then it will open the report of specific record from the value I input in the inputbox.
No I know this one has been done, and I have a form with a button that this works on. Here is my problem. I have a list of parts in a continuous form, I added a button to open that specific record in a detail view and it works just fine. I used an open form macro and put in the criteria
="[Description]=" & "'" & [Description] & "'"
I have tried to use this similar procedure for another form, it however has two subforms in it and I get a data type mismatch in criteria exception error. I suspect that it has something to do with the subforms but am not sure.
I am new to access i have a problem which is i have made a form which contains a subform and a read only subreport, what i want is the ability to select a record in read only subreport as in the picture attached and make a button that when i press on it, it should copy the values of the itemsID field, Packing field, ContainerNo field and origin field from the selected record and then paste them in the subform below.
Also i want to add more then one item, so the when i press on another record it should paste the values below the first record.
I have been trying for weeks to get my login form to open up to a specific record on the mainform. I have built a form out of my Employee tbl (mainform). The table stores (ID,Name, password, EmpNumber ect.) I built a subform in that allows the user to type in the number of overtime worked on a paticular day. I have disabled the navigation on the main form so users can't advance to the next user but have enable the natigation on the subform so a particular user can advance to the next week of available overtime to input data.The goal is to get user login form to display a particular record on the main form and open a different form in the user is a supervisor.
Option Compare Database Private intLogonAttempts As Integer Private Sub cmdExit_Click() DoCmd.Quit End Sub Private Sub cmdLogin_Click()
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1 If intLogonAttempts > 3 Then MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!" Application.Quit End If End Sub
I have one table with some info about my clients, I have a form, where I must choose this clients from combobox and then after clicking button Print must open report with info about specific (chosen from combobox) client and some another texts that doesn't change. Final result must be printed report as invoice.
I can't create report with only specific record information.