Forms :: Referencing A Subform Controls From Another Subform
Apr 15, 2014
I have a form with four unlinked sub forms on - I am hoping to
1) add a value from one subform to another and more importantly
2) update 1 subform when the other is amended...how exactly do I reference subform 2 from subform1.
I have tried me.parent!form2 and forms!mainform!form2.requery etc but can't get it right
View Replies
ADVERTISEMENT
Feb 16, 2007
Hello,
I need some help with a piece of code for a db.
This code checks to see if the last three characters on a ControlSource.Tag property are "Req" and if they are, tests if it's null or = 0 and if it is then it outputs a msg box stating that the control.ControlSource is required. It does it for every control on the main form.
This has worked.
Now, i need to allow for multiple subforms to be located on the main form along with their controls being tested as well. I want to start another loop for each time the conrol on the mainform is a subform.
I have that done so far by using "If TypeOf ctl Is SubForm Then..."
This is the part i need help with. I want to search all of the controls on the subform when it is a subform. I need to search all of the controls on the subform then, and i'm not quite sure of the syntax.
I've tried various somethings like SUBFORMCONTROL.Controls but that hasn't seemed to work...
If someone could help me, that would be wonderful!
View 4 Replies
View Related
May 27, 2014
On a main form i have a continuous subform listing Jobs.
On the Click Event i want to display the personnel and equipment separately in two additional subforms linked to the Job i have clicked on by JobID.
I have tried all sorts of references and currently have this:-
Forms!PersonnelAndEquipmentMovementFrm.PerEquipMov Jobs.JobID = Form!EmployeeSubform.JobID.Text
Which does not work?
View 4 Replies
View Related
Aug 12, 2015
I Open my Form
frm_process_ppl (single form)
which has the datasource as qry_process_ppl_2
on this form is a subform (continuous)
frm_process_ppl_orig
with the same data source linked by [ALINK].I want to run an append query when I click on one of the controls of the subform.On the subform there is a uniqueID called [LNK]
In the append query I have the following criteria for the LNK field [Forms]![frm_process_ppl]![frm_process_ppl2].[LNK]..However it is not working.I think my criteria is wrong.
(This worked fine with just one form but I have had to add an additional subform and the original form was continuous. I cannot add a subform to a continuous form so I decided to creat a single form to house the continuous form) I just cant reference what Im clicking in my query !!
View 2 Replies
View Related
Jun 24, 2015
I have a form and subform with the following names:
frmBasic
sfrmCustomers
I have a unbound txt field called txtCustName on the mainform
I want to populate this field from a field on the subform called CustName when the record is selected.
I also have an unbound combo box with the cust ids using the row source from the tables record source from the main form.
I tried the following Code:
Private Sub cboCustNum_AfterUpdate()
Me.Filter = "[Cust_ID]=" & cboCustNum
Me.FilterOn = True
Me.txtCustName = Forms.frmBasic.sfrmCustomers.Form.CustName
End Sub
This didn't work. So I put "= [Forms].[frmBasic].[sfrmCustomers].Form.[CustName]" in the control source of the text box on the main form I want populated.
The name doesn't appear in the field. I get #Name? in the field.
View 4 Replies
View Related
Oct 23, 2013
I have a multi select list box which I am trying to use to open another form and apply a filter based on the user's multiple selections.
List box - lstCatergories
Main Form - frmSuppliersSummaryCategories
Subform on Main Form - frmSuppliersSummaryCategoriesSubForm
The Subform contains the text box CategoryID
Here's my code which nearly works...
Code:
Private Sub cmdFilterSuppliers_Click()
On Error GoTo Err_cmdFilterSuppliers_Click
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
[Code] .....
My problem is that the control "CategoryID" is on the subform and I'm having massive problems trying to reference it. This is the part of my code that won't work:
Code:
DoCmd.OpenForm "frmSuppliersSummaryCategories", acNormal, , "CategoryID IN(" & strWhere & ")"
However; if I open the SubForm directly it works perfectly. I.e.
Code:
DoCmd.OpenForm "frmSuppliersSummaryCategoriesSubform", acFormDS, , "CategoryID IN(" & strWhere & ")"
To summarise... How do I reference the control "CategoryID" on the subform "frmSuppliersSummaryCategoriesSubform"?
View 4 Replies
View Related
Aug 16, 2013
I have a main form, lets call it FrmMain. In addition, I have a subform on FrmMain that has a tab control on it (frmSubform). What I would like to do is on form load, reference the tab control that is on the subform, loop through the controls/textboxes, lock them and change their backcolor. The code I am attempting is listed below, however, I am getting a "type mismatch error" highlighting this line:
PHP Code:
Set Frm = Forms!frmConsultingMain!FrmConsultingFeeDataÂ
Below is my code:
PHP Code:
Dim ctl As ControlDim Frm As FormSet Frm = Forms!frmmain!FrmSubformFor Each ctl In Frm.Controls   Â
If (TypeName(ctl) = "Textbox" Or (TypeName(ctl) = "combobox") Or (TypeName(ctl) = "listbox")) Then       Â
ctl.Value = Null        ctl.BackColor = vbYellow        ctl.Locked = True    End IfNext ctlÂ
View 10 Replies
View Related
Aug 13, 2013
I have a library database with a form called Author and a subform from a junction table. The junction table connects Title/Genre. It's many to many because I usually have a few genres for one book.
This is my problem. I want to add more information to the subtable that is in the junction table. For every record I would like to add also Book Group (I am a member of several groups and want to remember which one I read the book with) and Purchased From.
So I am assuming I have to have 2 lookup controls to be able to add Book Group and Purchased from since neither one is on the junction table (and they both come from tables). Or do I add them to the junction table?
View 3 Replies
View Related
Mar 30, 2012
I have a main form, 2 sub forms, and 2 text-boxes on the main form. I have a search box now for the first subform. Works perfectly. Once the users filtered based on name, I want them to be able to select that filtered record which would filter another subform.
Right? ok.
My first attempt was to assign the ID that was selected to a textbox on the main form, then automatically requery the second subform based on that value. I used this way on my search box. I'm sure there is a way to go directly from clicking the value to requerying the second subform, but i don't know it.
That being said even the indirect first attempt isn't working. It all has to do with the ".", "!", and ordering of this stuff. It has to do something with Parent child, but beyond that I'm at a loss.
Code:
Me.[Collateral] = Acct_Reference_id
Me.[Navigation]![textbox] = Acct_Reference_id
...
'Me!Subform1.Form!ControlName
'Me!Subform2.Form!ControlName
'Me.Parent!ControlName
I did find this very useful site [URL] ...... It shows what code you can use depending on where you are and what you're doing. Even with that as a resource, i'm still at a loss.
View 7 Replies
View Related
Oct 23, 2014
In the attached picture has a representation of my setup.
My main form has a listbox search form (taken from this site). The search results populate data in subform1.
In the detail section of main form has subform1 with 3 cascading combo boxes. I have queries set up that run the cascading combo boxes.
In the detail of subform1, I have subform2 with a combo box.
Today I decided to merge my search form and the other forms so I wouldn't have two pages. Everything used to work with no errors - but I can't figure out how to reference everything properly now.
I've tried every combination from here to reference things properly. Somehow, I'm missing something.
View 12 Replies
View Related
Aug 28, 2013
I have a continuous subform with multiple controls (textboxes) per row.
I'm trying to set up conditional formatting such that certain textboxes are highlighted based on comparisons with other textboxes within the same row/record.
What's bothering me is, I have managed it for one, but struggling to do it for others!
For example - I want to highlight 'similar' records (i.e. possible duplications) - and have managed this by adding a textbox across the length of the row and applying the following CF expression :
Quote:
DCount("[ID]","[tblMyTable]","[ID] <> " & "txtID" & " And [Field1]=" & "txtField1" & " And [Field2]=" & "txtField2" & " And [Field3]=" & "txtField3" & " And [Field4]=" & "txtField4" & " And [Field5]=" & "txtField5")>0
Works brilliantly - highlights all records where fields 1 thru 5 hold common values.
Now I want to highlight where two fields within the same record are different (i.e. they are driven by different data but should hold the same value)
Am trying this :
Quote:
"txtField3"<>"txtField4"
But it's not working - it's highlighting pairs of fields even though they do hold the same value.
Even tried switching it for a DLookup (which seems like doubling up on effort, but just to see if it worked)
Quote:
DLookUp("[Field3]","[tblMyTable]","[ID]=" & "txtID")<>DLookUp("[Field4]","[tblMyTable]","[ID]=" & "txtID")
But no dice? I can't figure out why the same basic logic which works so well for the first CF, doesn't hold for the second one.
View 5 Replies
View Related
Dec 12, 2014
So I am creating a Complaint Tracking Database with Access 2013. In my 'complaint entry form' I have added to ability to "Open" and "Close" the complaint. While the complaint is open the user is able to enter/edit data in the complaint (new or old). When the complaint is "Closed" (done so with a button on the form that prompts the user to enter a date of their choice) the user should not be able to enter/edit data in the given complaint. In my original thinking, I placed checks on various events (on load, after update, on click) that checked to see if the current complaint had a date in the "Close date" field.
If the close date field was null then that meant that the complaint was open and the the controls would NOT be locked. If the close date field was NOT null (i.e. a date was present) then the complaint was closed and the main form fields were locked but the data was still viewable and unless they "re-opened" the complaint they could not change the data.
Now, in the complaint entry form, I have a subform that acts as a action tracker that is used by the user to keep track of the actions taken on the complaint (i.e. they requested documentation from such and such on this date..etc). My problem through all of this is upon closing the complaint and locking the main form controls, my subforms data just vanishes! At first I figured the problem might be with the linking of master and child fields, so I made sure that I left the ID in the main form unlocked when I loop through my controls during the locking process. This did not solve my problem. Code below:
Private Sub Form_Load()
Dim ctl As Control
If Not IsNull(Me.close_date) Then
Me.FormHeader.Visible = True
Me.btnClosed.Enabled = False
Me.btnOpen.Enabled = True
For Each ctl In Me.Controls
[Code] .....
View 3 Replies
View Related
Dec 12, 2006
I cannot get this to work no matter what I do.
Form![MainForm].Form![Subform1].Form![Subform2]![Field]
The query containing this statement doesn't return anything and I get no prompts or error messages.
TIA
View 2 Replies
View Related
Oct 28, 2007
When I run the following code in a module -- to change the value of a label in a subform ("Employees Trained List subform" is a subform of "Contractors") I get an error that says it can't find the form (ie. Contractors). Also, if I eliminate "[Contractors]" the error says it can't find "Employees Trained List subform":
Forms![Contractors]![Employees Trained List subform].Form!lblThisYearTrainedDate.Caption = Year(Now()) + 1 & " Trained"
Any ideas on how to fix? Thanks
View 2 Replies
View Related
Oct 24, 2005
Newbie question: I have a datasheet view subform (called "UpdateProjectsSubform") in an "empty" form. I set it up this way because I was unable to get the Switchboard to open the subform in datasheet view.
I would like to have a command button to set filters in the subform. As I cannot have a button in datasheet view, I think my best option is to place a button on the master form that performs the command on the subform. I have tried every which way, but can't seem to get the correct syntax to reference the subform. I have searched this forum as well as other references with no success. Any ideas?
Thanks!
Nancy
View 6 Replies
View Related
Sep 2, 2004
I'm trying to check if a control on the subform is null. I've the following line of code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Form!FrmOrderInfoMain!SubFrmOrderInfo.ItemC ode) Then
Msgbox "Empty ItemCode"
End If
End Sub
..whereby FrmOrderInfoMain is the parent form and SubFrmOrderInfo is the subform. I get an error for this code as Im not sure what is the correct code to use. Thanks for the help.
Swee
View 7 Replies
View Related
Feb 23, 2015
I am trying to add a save/close button to a form that will only close if certain conditions are met and if they arnt then display a message box.I got the basics on how to save and close the form, do a simple if statement and display the message I want but the problem im running into is my subform can have multiple records and of those records each records status is set by 3 different checkboxes. I need all of those records status to be same when the form is closed.
if I do an if statement like
If Me!frmDataform1subform.Form!StatusID.Value = 1 then
docmd....
then all it looks at is the first record, how do I get my if statement to look at all the records in the subform?
View 2 Replies
View Related
Mar 9, 2005
Hi,
i'm working in access 97 and am having difficulties pulling a subtotal or referencing any fields on my subform on my main form. I've searched the forum and help and tried to apply the info provided, but i still can't seem to get it to work.
as far as i can tell this should work:
=[MySubForm].[Form]![TxtTotalStaffNumbers]
but i'm still getting the dreaded #Name? error.
anyone got any clues as to what i'm doing wrong?
what about the case where the subtotal i'm referencing is a calculation such as =Sum([Quantity]*[FacilityArea]). Should i still be able to reference it on my main form by pointing to the name of the field?
Thanks very much!
View 3 Replies
View Related
Nov 10, 2014
I've been trying : double click a field in a subform and paste the query results into excel. I already have good code to paste in the recordset, but this recordset must reference a control value in a subform.
The query works and shows the proper results manually, but when I run the Sub it throws a "run-time error 3061: Too few parameter. Expected 1."
I can't seem to set the parameters right. Tried EVERYTHING--except the RIGHT thing.
View 4 Replies
View Related
May 2, 2015
I have a form - purchase, and a subform purchase detail they are linked with a field "puid"..I need the dmax to give me the maximum auto number field "pdid" on the subform in a textbox on the mainform.
I used the control source code:
=DMax("[forms]![purchase]![purchasedetailds]![pdID]","[forms]![purchase]![purchasedetailds]","[Forms]![purchse]![purchasedetailds]![puid]=" & [Forms]![purchase]![puid])
and the simpler:
=DMax("purchasedetailds]![pdID]","[purchasedetailds]","[purchasedetailds]![puid]=" &[puid])
View 5 Replies
View Related
Jan 24, 2005
Hello,
my problem looks so stupid, but I'm not able to solve it..
I've a form with two subforms in it and one of them is behaving in a strange way.
I open the form and type something in a text box in the form. Now I can type something else in a text box in the first subform but I'm not able to write anything in a textbox in subform n°2. It's textboxes (and also other controls like combo,...) look like they are not enabled (but they are enabled!!).
This subform has also got a Button, and it works (It deletes current record).
If I close the form and reopen it and I go straight to subform n°2, now I'm able to insert text in it's controls, but I'm not able to edit the controls in the main form and in subform n°1.
I hope my problem is clear
Please help!!
View 1 Replies
View Related
Mar 31, 2005
Well this is going to take a bit of explaining, because my colleagues and I are totally baffled.
I have an Access 2000 front end connected to a Sql production server. I went to make some changes to my forms and subforms, but I did not want to do it with the live data. So I made a copy of the database to my own Sql server on my desktop. So far so good . . . Now when I opened my main form, my subform appeared, but its controls were invisible--I still had not touched the code.
I looked at all the properties for my form and subforms and it is set to Visible and Display always. Now, even stranger, when I advanced my records, if the subform had data its controls would become visible, and then disappear again when I reached a record that had no data for the subform (the main form and the subform are bound to two seperate tables within my database, all the subform controls are bound as are the majority of the form's controls).
Then I went to the code. Nowhere do I change the Visible related properties within the form/subform code. I decided to put a Stop in the Form_Current code of the subform and see what happens as I advance from record to record. What happened was that when I reached a record with subform data present the stop would be read and I would toggle through the Form_Current code. When I would reach a record with no subform data, the Form_Current code would not be read as evidenced by there being no Stop action.
Anyone have an idea of what's going on? Something gets changed when I connect to my local SQL server. Even when I reconnect to the production server the problem remains. Its like some property changes, although I cannot find it, and it is changed permanently. The only property I play with by code is that I enable the controls of the subform when there is NO data in the subform, and I disable the controls when there is data. This code follows:
Private Sub Form_Current()
On Error GoTo Err_Form_Current
If Me!AssignedNumber = True Then
Me!AssignedNumber.Enabled = False
Me!txtWTNumber.Locked = True
Else
Me!AssignedNumber.Enabled = True
Me!txtWTNumber.Locked = False
End If
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
Finally I tried to set Visible to true within my code for the individual controls, but that still did not overide the problem. I connect to my server via an ODBC connection to a .dsn.
Thanks in advance for bearing with me,
Tony
View 1 Replies
View Related
Jul 13, 2006
I have a subform (in form view) in a form that is used for data entry. When I open the form the subform is blank except for the navigation controls. The navigation controls are disabled though. If I switch to datasheet view I will see the column headers but there won't be any place to type data (no white boxes). This doesn't happen if my master and child fields aren't set up, but obviously that will show the wrong data and create other kinds of entry problems. Right now the tables are empty so that could be part of the problem, but I shouldn't have to manually enter a record so my form will look right.
View 12 Replies
View Related
Jan 26, 2005
Hi,
I have two subForms on separate pages of a Tab Control on a main form. I want to create a Textbox on one Form to display the month of a Date field on another form, using DatePart.
Using the On Current event, this works ok, if I have the 'other' subForm open in its own right, but I get message telling me it can't be found if i don't. Here is what I have...
Private Sub Form_Current()
If Not IsNull(Forms![Reviews]!SelectLessee) Then
Dim revDate As Date
revDate = Forms![subReviewPEST]!DateOfNextCreditReview
Me.Text118.Value = DatePart("m", revDate)
End If
End Sub
What syntax do I need, or how then can I access the control without having the subForm open itself, by getting to the page on the tab control, then to the control on the subform...
View 2 Replies
View Related
May 19, 2006
I have a form with 3 tabs...each tab has the same subform embedded in it.
There are 3 sequential records in the database, and my desire is to have each record display on its' proper tab.
How can I set filter criteria for each subform to append the record sequence identifier to the link master/child fields to ensure that only the appropriate record displays on each tab?
Basically, I trying to use tab controls with embedded subforms to display the many side of a one to many relationship. The parent form contains the data for the parentrecord, and I want the subform, with a tab for each related record, to show the child side of the data relationship. One child record per tab, utilizing the same identical sub-form for each.
View 1 Replies
View Related
Oct 1, 2015
I have some controls that I want to line up. Some are on the main form and some are on a subform. My questions is how do I do it? I normally
Select all of the controls then click on align and align top and left. Will that work here?
Again some controls on main and rest on subform.
View 3 Replies
View Related