Forms :: Use Same Code For Multiple Forms
Sep 11, 2013
I've been trying to figure a way to minimize my code in a module. I currently have three function built excalty the same way to work with three different forms. Each textbox in all the forms are named the same now what I'm trying to do is have the function identify which form called the function and where should the data be.
Code:
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveFormMsgBox "Current form is " & frmCurrentForm.Name
Once that is found. have something like this.
Code:
Select Case frmCurrentForm.Name
Case 1
WorkForm = Form1
Case 2
WorkForm = Form2
End
Code:
WorkForm.NameField = "John Smith"
No matter if all three forms are open the data should only go to the one that declared the function.
View Replies
ADVERTISEMENT
Jan 12, 2015
I'm opening forms to get data then closing using VB code.
Is there a way to stop the screen showing these forms as the code runs
something like Display refresh off then display refresh on.
Just to hide my workings.
View 1 Replies
View Related
Apr 11, 2014
I have a sub form that shows me a companies history. This subform is used on 2 different Parent forms. The record source for the sub form uses a criteria that looks at a companyID field on the parent to determine which records to return. My question is how do I have the query criteria depend on which form is currently opened? The criteria would look something like this:
[Forms]![frmCompanyHistory]![txtCompanyID] OR [Forms]![frmCompany_Project_Details]![txtCompanyID]
If I open the form with this criteria, I will be asked for a value in txtcompanyID for whatever parent form is not open. How do I properly do this without making multiple queries that are almost identical?
View 5 Replies
View Related
May 12, 2014
I have multiple sub forms and want to add specific text boxes of different sub forms into one another sub form. Then all sub forms are incorporated in one main unbound form.
View 6 Replies
View Related
May 27, 2013
I am a girl guide leader trying to make a faster way to keep track of my unit's completed badge and program work. I have made tables for every area I need (I started with one table but it was too large to change into a form).
In total I have:
- Basic Member table (main information like their name and how many years they have been in, whether they are still in the unit, etc)
- Program area tables
- Interest badge tables
What I want to do is be able to "add/edit" members from the main form, then go to all the sub forms for their program and badge work -- problem is, how to link them!
I am using Access 2007-2010.
View 2 Replies
View Related
Sep 23, 2014
I have forms that are printed based on a query parameter of [enter item number]. There are several of these forms that I would like to print at one time (with one command) making it easier for the user to gather their information at the beginning of the day. I also don't want to lose the ability to print them out individually as we do now.
View 14 Replies
View Related
Sep 20, 2014
I want create combination of navigation forms, navigation forms with two horizontal level and vertical level that link to navigation buttons in second level of horizontal navigation.
View 1 Replies
View Related
Apr 26, 2013
Is it possible to open multiple forms when the database opens? Currently only one form opens. I am using Access 2010.
View 5 Replies
View Related
Feb 8, 2005
i am converting dao to ado I am 20 forms in my mdb file and i am wondering if code behind the forms would also need some refreshment?
View 3 Replies
View Related
Jan 17, 2006
I have a Main Form with 10 Buttons on the Left side (Right side of the Form is Blank. On Click the Main Forms Closes and respective Forms opens based on the button I Clicked.
Now over here I wish to Keep the MainForm OPEN and subsequently open the other Form on the Right Side in Blank area.
Request for the SmartTips to startover -Thanks
View 1 Replies
View Related
Sep 25, 2014
I want to create a form that allows users to update multiple fields for multiple assets. Below is what I came up with:
Ideally, I'd like the subform to be filled in by having the user select multiple Assets from the S/N combobox field which would then auto-populate the "Type" field. Then they would fill out the appropriate fields they want edited in the top part of the form. They hit save and magic happens. This would also be nice because only assets they want edited would be displayed (easier on the eyes) and no distinguishing would be necessary. To do it this way, I know I would need to use a temp table but I wanna avoid using temp tables.
I know I can do this by adding a Yes/No field in the "Asset" table, setting the "Asset" table as the subform's recordsource, and then putting a checkbox in the subform and allowing them to check the assets that they want to edit (which would also allow me to sort it instantly so that checked Assets are at the top of the datasheet for easy viewing), but I would like to know if there's a way of accomplishing this without the use of checkboxes.
I know I could also use a listbox and that allows them to multi-select items, but I'm not sure if that allows me to group all selected items at the top of the listbox for easy viewing of selected items. Plus it would involve a lot of scrolling (there are over 2k assets).
View 2 Replies
View Related
Dec 20, 2006
All,
I have a search form (continuous) which filters results from the main table. I can then double click on one of the filtered results to open a new form (single) showing all the fields for that entry. Fine so far.
My question - There are ten different types of operation that can be displayed, all with slightly different relevant fields.
Which of these methods is more efficient:
1. Make ten custom made forms (the correct one displayed depending on the selected operation). - Easy to do but needs ten forms.
or
2. Have one form with all the fields added (only the correct fields made visible by code). - Complicated code.
What do you think ?
View 2 Replies
View Related
Feb 17, 2014
Code:
Private Sub Check237_Click()
If Me.Check237.Value = "yes" Then
Me.Text239.Visible = True
Else
Me.Text239.Visible = fasle
End If
End Sub
I am using the code above and what the desired action is when the Check237 is checked then the Text239 is visible for the user to put in a comment. However, as of now when the check237 is checked the textbox dissapears.
View 3 Replies
View Related
Jun 28, 2014
I would like to ask if there is a way so that using vba code to be able to closed any opened form in my database.
View 9 Replies
View Related
Jan 29, 2006
Hi,
I have the following situation.
I have a switchboard form which has 2 buttons (Add And Edit)
I have a patient record form, which has 2 fields, (DateRecCaptured and DateRecUpdated)
Both buttons on the switchboard open the Patient Record form (one opens it in Add mode and the other in Edit mode)
This is what should happen.
If I click on the add button on the switchboard, the patient record form should open to allow me to add a record. The system date should then automatically be saved in the DateRecCaptured field.
If i click on the Edit button and edit a record, the system date should be saved in the DateRecUpdated field. If no updates are made, the field shouldn't be updated. If you scroll among records, the DateRecUpdated field shouldn't be updated. When editing, the DateRecCaptured field should remain unchanged.
Thanx
View 1 Replies
View Related
Mar 26, 2015
I have a form I use for data entry, it needs to generate an id called RO Number and i need it be generated by access starting at number RO129036 and then keep adding sequentially, so RO129037 etc etc.
as i already have data in my DB that i need i cannot just reset any fields
having a table with just one field - the numeric part of the RO number so first one would be 129036 - so i need the form to pull this field, add 1, and then add "RO" at the beginning of it? i have really been struggling with this database
View 3 Replies
View Related
Apr 25, 2014
Can you have a saved (unsorted) query as a row source for a combo and then add some code to enable the combo to sort the list?
Reason is, I want three combos to use the same query for finding records in different ways, but need the query to be saved, not a query built by the query builder that access takes you into from the row source on the combo data tab?
I only need the data listed in each of the combos to be sorted by one column in each of the combos.
Have seen something about bubble sorting, but not sure if this is OTT or even could be applied to this?
FYI, this is not a cascading situation.
View 2 Replies
View Related
Mar 20, 2015
So in my database i'm creating a live form that will open up a list of patients and when they are seen. one of the bits is a button that before they arrive says "Not Arrived" and after they arrive it says "Arrived". The code works fine:
Code:
Private Sub Command68_Click()
Dim C1 As String
Dim C2 As String
[code]...
The problem is after clicking the button on any of the records, it changes the text on all records, to wit: I tried to attach images or links to images, but my post-count is too low. The before-click screenshot is /3QnBkgG on imgur. The after-click screenshot is 9VZWzzp on the same site.
Bear in mind I've only clicked the button (it's white, so it doesn't look like a button) on the top record.The form is set to continuous forms, not sure if that has anything to do with it.how I can get the code to run on individual records, rather than applying the first-record's results across all records?
View 12 Replies
View Related
Jul 22, 2014
I'd like to do the following: when the user does something on Form A, Form B has to be open and the Forms should be located on the sides (Form A to the left side, Form B to the right side) of the display so the user can see them at a time.
However both Form A and Form B has an automatic centering function set when used alone.
Is there a way I could push this from code? I can't fine anything like that among the form's property.
View 2 Replies
View Related
Jul 7, 2015
I have a form in which job times for individuals is entered. As the data is entered, a macro fires to calculate various costs (Nat Ins/Pension/Total cost etc etc), and that data is stored in a table.
I now have written code to enable the inputting of the data into the database directly from the Excel sheet in which the data is first entered - this is great as it cuts out a data entry repeat and will be a big big time saver.
View 9 Replies
View Related
May 20, 2014
I currently have two forms. One being my main form and the other being a pop-up form to update e-mail addresses. On my main form, I have a button that is currently programmed to generate several e-mails. Before those e-mails are generated, I would like the pop-up form to appear asking for any updates to e-mail addresses. Once the pop-up form is closed, I would like the code on my main form to continue.
View 2 Replies
View Related
Dec 19, 2014
In the initial Form_Open code there is a string that fails before the form is open, preventing me from opening the form and accessing the VBA code to correct the problem.How can I access the VBA code to correct the problem if it otherwise prevents me from opening the form so I can access the VBA code?
View 7 Replies
View Related
Nov 28, 2013
I have two text fields:
their names are :
field 1 ="txtfilter"
and
field 2: "text333"
How can i change the names of the two fields with vba code?
I need field 1 to get the name of field 2
and field 2 to get the name of field 1
This will be temporarily.
using access 2013
View 5 Replies
View Related
Aug 24, 2014
Quote:
Private Sub Save_Click()
If IsNull(cboEmpName) Then
MsgBox "Please Select Employee Name"
Me.cboEmpName.SetFocus
End If
If Me.txtNoofDaysWorked.Value = "0" Then
MsgBox "Please Enter No of Worked Days"
[code].....
View 1 Replies
View Related
Sep 4, 2013
I have an order form that auto-populates details from the customer table into adderss and contact controls. But I don't want it to auto-populate when the underlying order table already has data in the related fields. Here is the code I use on Load form event...
======
Private Sub Form_Load()
'Use this version if the ID is a number
Dim x As Variant
Dim strControl As String
Dim lngID As Long
'If parameters exist, use them
If Len(Me.OpenArgs) > 0 Then
[Code] ....
View 2 Replies
View Related
Aug 25, 2014
I have a form that requires at least a transaction code (from a combo box) and a total value field (numeric) to be entered.I have used the following code but when I click OK on the message box the form is closed.I want it to remain open so the user can enter the fields and properly save the record. As the code is in the Before Update event it does the same thing if I have Cancel = true.
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Check to make sure the TransCode has been selected and the total field doesn't = zero
'If Me.cboName.ListIndex = -1 Then
' MsgBox "A value is required for ...."
' Me.cboName.SetFocus
' Cancel = True
[code]....
View 4 Replies
View Related