Access Elements In A Sub Form From Main Form
Jun 9, 2006
I have a form (called DeliverableDescription ) that has the following buttons: close, and save
the main from has a sub form (called DeliverableDescriptionsubform) that is viewed as a datasheet
also I have a table called DeliverableDescription that has three columns (outline number, name, and group number)
the DeliverableDescriptionsubformshows data from DeliverableDescription (only the outline number and name)
this DeliverableDescriptionsubform is used to update the DeliverableDescription table (through copy and paste from another source)
what I need to do is populate the group number column when the DeliverableDescriptionsubform is updated
the group number is just the first part of the outline number (i.e. if the outline number is 20.45.35.1.4.9 then the group number is 20)
I want to create a command in the save button that takes the string value of each item in outline number column and do some simple string manipulation to it then populate the group number
my approach is to have a select query that gives me all the outline number then through a loop iterate through each one, performing the string manipulation and update to the table.
my question is how to access elements in a sub form, since the save button is in the main DeliverableDescription form
also is there a better way to do this?
thanks for any help you might be able to offer.
Code:Dim ws As WorkspaceDim db As DatabaseDim rs As RecordsetDim OutlineNum As StringDim queryResult As StringDim returnResult As StringDim SearchChar As StringDim Pos1 As IntegerDim TotalLen As Integer OutlineNum = "SELECT DeliverableDescription.OutlineNumber " & _ "FROM DeliverableDescription " Set ws = DBEngine.Workspaces(0) Set db = ws.OpenDatabase("N:statusReport_Test.mdb") Set rs = db.OpenRecordset(OutlineNum) Do While Not rs.EOF queryResult = rs.Fields(0) TotalLen = Len(queryResult) SearchChar = "." Pos1 = InStr(queryResult, SearchChar) returnResult = Left(queryResult, Pos1 - 1) DoCmd.RunSQL ("Update DeliverableDescription SET DeliverableDescription.TeamLeadNumber = returnResult " & _ "WHERE DeliverableDescription.OutlineNumber = OutlineNum ;") queryResult = "" SearchChar = "" Pos1 = 0 rs.MoveNext If rs.EOF Then Exit Do End If Loop DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
View Replies
ADVERTISEMENT
Jun 24, 2015
I have a database with a Main Menu Form, containing a Button that loads my main data entry form. When the Button is Clicked portions of the data entry form that is loading shows through the Main Form Background (e.g. portions of the navigation bars, and portions of the boarder on the form that is loading.)
View 5 Replies
View Related
Dec 1, 2005
I have a subform which makes a change to a field on the main form. When focus is returned to the main form, the BeforeUpdate and AfterUpdate events fire. Why? I thought from the form's perspective, the subform is just another control.
BTW, I get the same behavior if I modify the field from within the Exit event of the subform control.
In either case, the main form's Dirty event is NOT triggered.
View 2 Replies
View Related
Nov 2, 2005
Hi,
I have a form with a couple of sub forms, one of the sub forms only has a check box and a txt field and both are required before moving on to another record.
I have this following code that works partly, but it only works if one of the fields have info entered. It doesn't however stop the user from tabing through the sub form without entering 'any' data in either one.
---------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Trim(Me!txtContactAgentName & "") = "" Then 'Validate Name Field
MsgBox "Gotta Enter Your Name!"
Me!txtContactAgentName.SetFocus
Cancel = True
ElseIf Me!ynCCContactLogLeft <> True Then 'Validate CheckBox
MsgBox "Gotta Have a checkmark in Logged!"
Cancel = True
End If
End Sub
---------------------------------------------
Also the below throws up an error when I know it's got all the correct information.
------------------------------------
Private Sub txtContactAgentName_LostFocus()
Forms.frmAllCustInfo.SetFocus
Forms.frmAllCustInfo![AddNewCustomerRecord].SetFocus
End Sub
-------------------------------------
Can anyone advise?
thanks in advance
View 4 Replies
View Related
Dec 12, 2005
I need to have Access open with a form that does not take up the entire screen and I don't want to see the Access stuff behind it. How can I make just the start up form appear when I open the db?
Thanks for any help...
View 3 Replies
View Related
Aug 27, 2014
On the form: User enters first name, then last name. Upon updating the last name field, I would like another form to pop-up and display all the people with that same first name and last name that the user just entered.
On the pop-up form: All of the matching first names/last names are listed with a button control beside each record that says 'Select'. The user clicks the select button beside the record he/she wants. This pop-up form closes and all of the data from this selected record is now showing on the original form.
So far, I have a query/form that pops up only showing the matching first/last names. I'm having a hard time getting my original form to auto-populate with that record that the user selects on the pop-up.
(Also my main form is actually a sub-sub form - so in my trials I could've been massacring my syntax trying to point to it.)
View 5 Replies
View Related
Nov 30, 2005
I'm supporting some Access/VBA code which includes the following behavior:
When an update is made in a (linked) child form, the current date/time is written to a textbox on the main form via
Me.Parent!txtMod = Now
Likewise, the BeforeUpdate event of the main form updates the same field (and then does a bunch of form validity checks, possibly followed by a Save).
When we upgraded to Access 2003 from Access 2000, a problem erupted:
When the user returns to the main form (by clicking on any control outside the subform), the following message is issued: "This record has been changed by another user since you started editing it (etc.)..."
At this point the user must choose between "Save Record", "Copy to Clipboard" and "Drop Changes".
Conceptually, I see why this is happening (though I wonder why Access 2000 didn't flag it). The subform is the "other user". When the main form is returned to, it is "Dirty" (unsaved update), so the main form's BeforeUpdate event fires, and attempts to update the field again (Me.txtMod = Now). Since there is a pending change to the field, an error dialog pops up.
As a quick fix, I replaced the code in the subform with a flag ("Hey, I've been updated!"), which the main form checks on the Exit event of the subform control. But that seems a horrible solution. Surely there's a better way?
Notes:
1. It would be preferable to have the timestamp updated right away by the subform, though having it updated when the subform loses focus is better than nothing.
2. Since a subform is a control from the main form's perspective, I'm surprised that a change to that control doesn't render the main form "Dirty". I guess from a database standpoint it makes sense (the form's table isn't getting updated at all; just the subform's). But then, how does the main form know that the subform has been updated?
3. I tried catching the error via Form_Error. I can make the dialog not appear via "Response = acDataErrContinue", but unfortunately it defaults to dropping the changes (old and new), rather than saving the new.
View 14 Replies
View Related
Nov 21, 2006
I was hoping someone could let me know how I can convert my MS ACCESS database file (.mdb) so that when user(s) run/open the database, they cannot see, nor have access to the tables (which are linked from a separate DB with just the tables), forms, queries, etc... (the elements). Right now, you can open the file, the switchboard runs, but you can still see and navigate to the tables/forms/queries seen in the background.
Is there a quick and simple way to turn this into an executable-type file where you cannot see the elements in the background?
View 3 Replies
View Related
Jun 6, 2013
I have one table containing name of restaurant with its address etc. Then i created another table to list out the restaurant workers names and details. Just as an example,
Table:Restaurant
Restaurant name
Address line 1
Address line 2
Restaurant #
Website
Table:StaffContact
Staff Role
Name
speciality
email
phone
I have the main form that has all the restaurant details only. And i have another form containing the Staff information. Please note the two table have a relation and it works well.
Now to make it user friendly(basically easier for the lazy ones), I dragged the staff contact form on to my main form and displayed it as a datasheet(basically a sub form).
Now, my boss does not want users to add/delete on this sub form(datasheet). So,he wants me to create buttons to open new record of staff for each restaurant(new form)
My issue is with opening a new record to enter a new person to the staff list and give them a role as well in form view.The new form has
So i ran a Macro, with open form with Where condition
Code:
[Staffcontact]![Rest Name]=[Forms]![MainForm]![RestaurantName]
But, it does not work .
View 2 Replies
View Related
Jul 24, 2013
I have a form, which is comprised of a sub form, and some of the text box controls sided with a button, and the event had been written to the button.
Now, to give a note on how had the sub form had been created is firstly taking a clone of the "Payments" table and using it as a datasheet, and then create a sub form in the form, it works fine
View 2 Replies
View Related
Nov 28, 2013
I have a main form (tsTimeSheetMain) which contains a sub form (tsTimeSheetDataNewSub) in data sheet view. When I click off one row onto another row in the sub form, it triggers this code:
Forms!tsTimeSheetMain!ProjectMonSum.Requery
i.e. it tries to requery the ProjectMonSum field (on the main form) which is a dsum calculated field. This works fine and updates the ProjectMonSum field (which dsums values from the same datasource as the subform.
However, this seems to put the cursor back to the top left field in the subform (datasheet view), rather than leave it in the field I click on (in the subform).
Why is this happening and what is a decent workaround this issue? I just want to update the calculated dsum field each time you update values in the subform.
View 8 Replies
View Related
Apr 11, 2005
I have one main form with 3 tabulated sub forms.
My main form consists of two fields.
When the user clicks tab 2 (subform 2) or tab 3 (subform 3) the main fields should hide
I tried to achieve this by using the on click event at the tabbed forms. I referenced the two main fields and used the visible property followed by a form requery. It didn't work.
thanks in advance
View 1 Replies
View Related
Aug 25, 2005
Hi all,
I've added a message box to what is basically a standard simple to use access control, "closeForm", I'm a newbie working on learning access vb. I'm guessing my code if fudged. Any help is greatly appreciated.
Private Sub Close_Click()
On Error GoTo Err_Close_Click
Dim Answer As Integer
Answer = MsgBox("Press Ok to Close, Cancel to Continue.", vbOKCancel + vbQuestion, "Exit Data Entry?")
If vbOK Then DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
Thanks to all in advance
View 5 Replies
View Related
Sep 2, 2006
I'm not sure how to search on this, even in the advanced search. If this has been answered, could you point me in the right direction?
I have a main form AddNewCompany (the infamous tab control that now works - thanks to your combined efforts). On it I have a command button that pops up a form of continuous forms with all the companies in the table (the query calls the CompanyID and CompanyName fields only). I have attached an image of the interface.
This means the user can see if the company already exists and doesn't enter it again. (I'm sure there are more effecient ways of doing this, but this is simple and it works. I also know key fields should be autonumbers instead of text, but I have reasons for doing it this way).
What I would like to be able to do is click on the CompanyID field and have the companies information show up in the main form.
View 14 Replies
View Related
Sep 4, 2006
Can anyone see what I am doing wrong?
I have a main form that has a tab control on it. The main form is called frm_AddNewCompanyContacts. It is opened in edit mode. To see if a company exists I use a command button to call a popup form with a list of all companies' IDs and names. I then want the user to be able to click on a commad button on the popup form to take the main form to that record. After an intial post, and subsequent search, I found the appropriate code. This is what I am using for the onclick event of the command button on the popup form:
Private Sub cmdGoToCompany_Click()
Dim rst As Recordset
Set rst = Forms![frm_AddNewCompanyContacts].RecordsetClone
rst.FindFirst "[CompanyID]='" & Me![CompanyID] & "'"
If rst.NoMatch = False Then
Forms![frm_AddNewCompanyContacts].Bookmark = rst.Bookmark
End If
End Sub
When I click on the command button I get an error message:
"The expression On Click you entered as the even property setting produced the following error: A problem occurred while Microsoft Office Access was communication with OLE server or ActiveX Control (I don't have an ActiveX Control).
*The expression may not result in the name of a macro, the name of a user-defined function, or [Even Procedure].
*There may have ben an error evaluating the function, event or macro."
View 10 Replies
View Related
Nov 13, 2004
I'm trying to sum up the hours of a sub-form on the main form. I've followed the instructions in Access Help so far. I've created a text box in the footer of the sub form with the following control source:
=Sum([Mon])
which should sum up all the hours in HoursMon fileds.
Then I've created a text box on the main form with the following code in the Control Source
=[frmTshtProj Subform]!SumMon
But it doesn't work. I get a #Name? appear in the box instead of a total. Any ideas?
Thanks in advance
S
View 6 Replies
View Related
Jun 11, 2007
Hi
I need code to open TeacherDetailFrm form Main form.
I have TeacherStudentSubFr*m on the Mainform, FirstNameTxt on the TeacherStudentSubFr*m, and TeacherDetailFrm.
I need code to open the TeacherDetailFrm By double click on the FirstNameTxt.
I use this code but no data come and query dialog box come.
Private Sub FirstNameTxt_DblCli*ck(Cancel As Integer)
Dim DocSubForm As String
Dim DocText As String
DocSubForm = "TeacherDetailFrm"
'DocText = "[Result]=" & "'" & Me![result] & "'"
DoCmd.OpenForm DocSubForm, , , "[ FirstNameFld ]=forms![TeacherStudentSubFrm]![ FirstNameTxt]"
End Sub
I like to upload the file but no way in this forum
View 2 Replies
View Related
Jan 23, 2015
I have a 'main' table with a Project_Number that links all the data in my db together. I have another table that uses that Project_Number as a lookup field to connect that tables data to the main data. I created a 'main' form that has the ability to enter data for the 'main' table. I want to be able to press a button and have the second tables form pop up and add that that specific Project_Number. I added the button and went through the wizard process. I then added the linking info through the builder. It works fine if there is already data entered for the project_number in that specific field. but if the field is empty, the popup window doesn't recognize a project_number and doesn't add it to that record. below is what I am using. The project_number in the 'main' table is text and the Project_Number in the 2nd table in a number since it is a lookup field.
Private Sub CongressionalDistrictCmd_Click()
On Error GoTo Err_CongressionalDistrictCmd_Click
Dim stDocName As String
[Code]....
View 9 Replies
View Related
Nov 23, 2013
So I have made all the necessary forms to start working with my Access, and now I need a main form, a home where I should put all the buttons to enter each form.I have used the Navigation Control on a New form URL...
A row with buttons appeared, and I complete the property: Navigation Target Name with the target form, but it is giving me some trouble with a searchForm and a Query. Every time I enter this form (using nav control), Query asks for an Input.
View 2 Replies
View Related
Mar 22, 2013
I have converted an old Access 97 database to Access 2010. Mostly it works fine but I have a major issue with the invoicing forms. It was working in the old database but I cannot get it to work in this version.
I have the usual invoicing option where the lines of the invoice are displayed in a sub form for that customer and line totals calculated. This works fine. I have a sub form total text box in the footer of the sub form which I want to pick up from the main form so that I can add the delivery charge and VAT.
View 6 Replies
View Related
Dec 20, 2011
I'm working on a project that has two tables. "Calls" and "Customers". The Customers form has a subform, "Calls Subform" in it. When you click on the (New) Hyperlink a new form opens, "Call Details". I would like to pull information off of the "Customers" Form and insert it into the newly opened "Call Details" form.
Problem #1) Home Phone (named "Phone" and Text223 (named "CID"): are both bound controls so I have to do this in an OpenArgs type process.
Further details:
On "Customers" the following is true:
"25" is the "ID" for that customer on the "customers" table
"Home Phone" is the home phone number on the "Customers" table
On Call Details the following is true:
Home Phone is Bound to a table "Calls" and needs to pull it's data from Customers Form..Text223 is CID and bound to the table "Calls" and needs to pull it's data from "Customers" form.
View 14 Replies
View Related
Jan 24, 2012
I have a main form where information for a particular part number or job is entered. Should the part number not yet exist, Access will let you know. I have a button within the main form that opens up the Form_EnterPartNumber form which allows you to enter the new part number.
What I would hope to be able to do would be to refresh (requery?) the main form after creating a new part number and closing the Form_EnterPartNumber form..........but, keep the main form on the current record instead of resetting back to record number 1.
Is this possible?
View 1 Replies
View Related
Nov 12, 2006
The situation is like this:
I am designing a db for a dental clinic. I created 3 tables as follows:
1.T_Patients (P_Code(PK) and other fields)
2.T_Diagnosis (P_Code(Fk), ToothRecId (PK) and 32 text fields for 32 tooth named (UR1 to UR8, UL1- UL8 for Upper left / right Arch and LR1 to LR8, LL1 to LL8 for Lower left / right Arch)
3.T_Pmts (P_Code (FK), PmtRecId(PK) and other fields
I created one main form based on T_Patients tbl and similarly another 2 forms from other 2 tables. In the main form I placed 1 sub-form and 2nd sub-form. Bothe the sub-forms are Master / Child relationship on form over P_Code field in the main form.
Single character length has used for all the 32 text fields in table T_Diagnosis. So only one single B, C, D, F, M could be entered.
Normally we search patient’s profile by patient’s code or by name that displays in the main form. But the client needs to search patient’s record by tooth criteria.
There may many tooth fields in the first sub-form that are null and only some of them with any one of the B, C, D, F, M character. Bcz there is very rare chances of damaging all 32 tooth of the patient.
Now my clients want to search based on the data which are B, C, D, F, M characters. Means once he types C (stands for Cavity) in a search text box then it should bring all the sub-form records that hold value C in any of the 32 fields.
1.How can I do this when the search based on SUB-FORM and not over the main form?
2.The entered criteria value might by in other field also. Like say if entered C then this value may be in any of the 32 fields. So how it would bring all records?
I am confused how to do it. I attached a pic of my form for your ready ref. :confused:
I would really appreciate if somebody could help me.
With kind regards,
Ashfaque
View 3 Replies
View Related
Aug 11, 2014
I have a database that tracks workorders and then the associated invoices that result froma workorder. The process is that the user creates a workorder and when an invoice related to the workorder comes in, they register the invoice and select the workorder it belongs to.I have a form (DFRM_PayrollWorkorders) that allows the user to display the workorder. This form contains a sub form DFRM_PayrollInvoices_Summary that displays any invoices that have been registered against the workorder id. Sample screen attached. In the sub form, I have added two expressions ,
=Count([InvoiceNumber]) and =Sum([InvoiceValueTotal]).
In the work order form I have added two expressions, =[DTBL_PayrollInvoices_Summary].[Form]![Invoice_Count] and =[DTBL_PayrollInvoices_Summary].[Form]![Invoice_Sum].
The above simply displays the total invoice count and total invoice amount for any invoices associated with the work order being dsiplayed on screen.
My issue is, whenever there are no invoices for the work order, I get #Error in the =[DTBL_PayrollInvoices_Summary].[Form]![Invoice_Count] and =[DTBL_PayrollInvoices_Summary].[Form]![Invoice_Sum] expressions.
Ideally, I'd just like the count and sum expressions to show blank or 0.
View 2 Replies
View Related
Aug 23, 2013
I am trying to improve my code by making it more readible. The following code works, but it is certainly not the most efficient way. I`m trying to write a loop to make certain elements in an Access report visible/invisible, but I can`t address the visibility property of these items while iterating over i.
Code:
DoCmd.OpenReport "tblInterval subreport", acViewDesign, , , acHidden
Reports![tblInterval subreport]!BoxInsp1.Visible = False
Reports![tblInterval subreport]!BoxInsp2.Visible = False
Reports![tblInterval subreport]!BoxInsp3.Visible = False
[code]...
View 2 Replies
View Related
Mar 30, 2005
Hi
I apologise for the newbie type question. However, I am a VB not an Access programmer and the syntax for sub-forms always confuses me! (The FAQ by "SJ McAbney" did not help.)
I have an ADP project (pointing to SQL Server, if it makes any difference) and have implemented a security model based around Active Directory. I use this to set a public variable called "lngSecLevel", the higher it's value the more security the user has.
To impose the security, each form has code similar to the following in the form's open event:
If lngSecLevel = 1 Then
Me.AllowEdits = False
Me.AllowAdditions = False
Me.AllowDeletions = False
ElseIf lngSecLevel = 2 Then
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = False
ElseIf lngSecLevel = 3 Then
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = False
ElseIf lngSecLevel >= 4 Then
Me.AllowEdits = True
Me.AllowAdditions = True
Me.AllowDeletions = True
End If
(so "me" obviously is the form)
I have a sub-form "frmFile Damages sub" which is available on multiple forms (i.e. several different and distinct forms, which display the information on the "frmFile Damages sub" sub-form).
The issue is that it is possible for the same user to have different levels of security depending upon which "master" form is displayed (this is a business requirement).
As the sub-form's open event is called before the master form's open event, I cannot just place similar to the following in the sub-form's open event:
Me.AllowEdits = Me.Parent.AllowEdits
Me.AllowAdditions = Me.Parent.AllowAdditions
Me.AllowDeletions = Me.Parent.AllowDeletions
The alternative is to modify the main form's open event with the following code (but after my first snippet):
Me.[frmFile Damages sub].Form.AllowEdits = Me.AllowEdits
Me.[frmFile Damages sub].Form.AllowAdditions = Me.AllowAdditions
Me.[frmFile Damages sub].Form.AllowDeletions = Me.AllowDeletions
However, I cannot get the above to work, irrespective of the use of "!" and ".form".
Any help would be appreciated.
Marcus.
View 2 Replies
View Related