currently using Access and would like to add a list box to a form.
Is it possible to add a list box on a form which contains data from a text that is held in another form on the same Access database?
The text box isn't stored as data in my database so struggling as to how I would could do this.
Thanks
Assuming the other form is open, you can dynamically populate the list box.
For example I have two forms.
Form 1 (called Frm1) has 1 textbox, called txtItemList. I've populated this with "1,2,3,4"
Form 2 (called Frm2) has 1 listbox, called lst1. Frm2 has an event on load that populates the listbox with data from Form 1.
Private Sub Form_Load()
Me.lst1.RowSource = Forms!FRM1.txtitemlist
Me.lst1.RowSourceType = "Value List"
End Sub
Now when Form 2 loads, it populates lst1 with values from txtItemListfrom Form 1.
Related
I'm beginning to develop a UI for various departments in my office to support the viewing and editing of customer records.
I have a navigation form with each tab being a separate table within the database. One is customer specific info like SSN, first/last name, etc. The next would be address, the following is contact info, orders, etc.
The first form is where they select the customer. All following forms will depend upon who they select here. I need to be able to retain the Record ID from the first form as they navigate elsewhere. Currently, the form resets each time it loses focus.
Is there a way to enable this? The following forms will be filtered according to what they select in the first couple.
Store the Record ID in the Form's Tag property.
Then:
If loading a new form, you can pass it to the form's .OpenArgs property.
If loading a subform, you can get it through the .Parent.Tag property.
User selects a record:
Me.Tag = Me![Record ID]
Opening a new form:
'Open form
DoCmd.OpenForm "frmName", acNormal, , , acFormPropertySettings, acWindowNormal, Me.Tag
'Filter Form
Private Sub Form_Load()
With Me
If Not IsNull(.OpenArgs) Then
.Filter = "[Record ID]=" & .OpenArgs
.FilterOn = True
End If
End With
End Sub
Loading a subform:
'Filter Form
Private Sub Form_Load()
With Me
If Not IsNull(.Parent.Tag) Then
.Filter = "[Record ID]=" & .Parent.Tag
.FilterOn = True
End If
End With
End Sub
Lastly, if navigating between forms, store it in each form's Tag property.
Although not implemented with the navigation form, an article and a full demo on syncing subforms is here:
Synchronizing Multiple Subforms in Access
I need to create my own "navigation" form in Ms Access. Basically, I have a MAIN form that has one field named LotNumSelect
Then, buttons representing each form the user would like to view.
Button1 - Customer
Button2 - Job Data
etc.
Once the customer clicks a button, the procedure would open the corresponding form in the subform window to the record matching the LotNumSelect field.
So far, I have this.
Private Sub ContactInfo_Click()
Main_Customer_Sbfm.SourceObject = "Main_Customer_Sbfm"
Forms!Form1!Main_Customer_Sbfm.Form!Lot_Number.SetFocus
This nicely switches the form within the subform. the problem is how do I get the form within the subform find the record associated with the data in the LotNumSelect Field?
I tried this..
DoCmd.FindRecord LotNumSelect.Value, acEntire, , acSearchAll
but it's giving me a runtime error of "2162"
"A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.
I have a main form with a subform. The subform is continuous and shows all of the records. The main form works great for adding and editing records. I need to be able to double click on a record in the subform and that record be displayed on the main form for editing.
By experience I reccomend you to achieve what you are trying by placing two subforms into the master one. In one you have the list and in the other the details.
In the master form you place a hidden link field that is populated when you doubleclik on the list.
This field, let´s call it [link] is the Link Master Field in the detail subform, and the Link Child Field is the id (primary key) to identify your selection.
This will link your double click (or simple) with showing the details.
I found a solution that works to move to display the record from the subform in the master for editing.
In the DblClick event on the subform I put in the following code:
Let Forms!FrmNotes.CboNotesID = TxtNotesID 'TxtNotesID is the ID on the subform
Call Me.Parent.DisplayRecord
On the main for I created
Public Sub DisplayRecord()
CboNotesID.SetFocus
DoCmd.SearchForRecord , "", acFirst, "[NotesID] = " & "'" & Screen.ActiveControl & "'"
End Sub
libreoffice Base 4.3.3.2
Opening a Form page by name and then close the current page form like this work:
oForm = ThisDatabaseDocument.FormDocuments.getByName("SecondForm")
oForm.Open
oFormC = ThisDatabaseDocument.FormDocuments.getByName("CurrentForm")
oFormC.Close
but is there a way to close oFormC without writing by hand his name?
trying with:
oFormC = Event.Source.Model.Parent
oFormC = ThisDatabaseDocument.FormDocuments.getByName(Event.Source.Model.Parent)
oFormC = getParent()
return an error of var not set
Can't find any help in documentation.
The term 'form' in LibreOffice/OpenOffice is confusing because it refers both to the entire document (typically a Writer file) and also to each group of form controls inside that document. So each form document can have many forms (meaning a group of controls) inside it, and forms (groups of controls) can have sub-forms.
This code gets a form document (a Writer file embedded inside a Base file):
oDoc = ThisDatabaseDocument.FormDocuments.getByName("SecondForm")
This code gets the form that is a group of controls and that contains the control which triggered the macro: oForm = Event.Source.Model.Parent
Another way to get a group of controls inside the form document in which the macro was triggered: oForm = ThisComponent.drawpage.forms.MainForm
Replace "MainForm" with your actual form name - form here meaning a group of controls. You can see the names of forms and subforms that are inside a form document by opening the Form Navigator window. Make sure the toolbar Form Design is visible; the Form Navigator icon is the sixth from the left or top, looks like a rectangle with a compass in the upper right corner.
You may have guessed from the previous code how to close the document that is active when the macro is triggered:
ThisComponent.close
I have a form named UI(Navigation Form) in MS Access 2010. I have two more subforms SEARCH and RESULTS as tabbed forms in UI. After I search in SEARCH form, when I click the RESULTS tab I want the value from a combo box named 'cmbID' in SEARCH to be displayed in a label named 'lblAIPIDDisp' in RESULTS form and then display additional labels. So, I gave the following code in the navigation Button Click Event:
Private Sub NavigationButton32_Click()
Form_RESULTS.lblAIPIDDisp.Caption = [Forms]![UI]![SEARCH].cmbID.Value
End Sub
But I get Run Time Error 2465. So, I tried searching in SEARCH form separately and gave the following code in Form Load Event of RESULTS form:
Private Sub Form_Load()
Form_RESULTS.lblAIPIDDisp.Caption = [Forms]![SEARCH].cmbID.Value
End Sub
Now, I searched in SEARCH Form and clicked on RESULTS form. I was able to see the value in Combo Box 'cmbID' in SEARCH Form in the label 'lblAIPIDDisp' in RESULTS Form. So, I think there is something wrong in referencing subforms RESULTS and SEARCH in the Navigation Form UI. Help needed in this point.