I have on the MDIparent a Save button. My issue is I am on one of the child forms and have filled in all data in textboxes and then I would click the SAVE button on top of my MDI parent. That button checks what is the activechild and calls routine on the form to Insert/Update records in database.
But when I click the save button in debug I see if find the correct child form and code goes where I would it to but all the Txtboxes.text are = ""
Here is the code on the button on MDIParent form.
Select Case Me.ActiveMdiChild.Name
Case "frm1"
frm1.btnSave_Click(sender, e)
End Select
When the case is matched and goes back to frm1 none of the textboxes have values.
I know I am missing something.. any help
Related
I have a datagridview in a form and it opens within a panel. When it opens you can't click any of the cells in table. You can click the cells when the form opens not in the panel. I'm guessing that it's something to do with the way the form opens within the panel, But i'm not sure.
I'm able to reorder the table and resize rows.
People.WindowState = FormWindowState.Maximized
People.FormBorderStyle = Windows.Forms.FormBorderStyle.None
People.Visible = True
Panel2.Controls.Add(People)
Image of table within panel
If you cannot or will not extract your datagridview from your people form (and throw the peopleform away), add this to the People form:
Public Readonly Property TheGrid As DataGridView
Get
Return Me.DataGridViewNameHere
End Get
End Property
Then add the grid to the panel, not the whole form:
Panel2.Controls.Add(People.TheGrid)
I have a search button on a form (form1). The results of the search is displayed in a subform ("SearchResult_sub") on a second form ("frmEquipSearchResults"). The reason I display the result in a subform is that frmEquipSearchResults has buttons to perform action on the search results. So when I open the form the first time everything is fine. But if I leave the result form open , go back to form1 and do another search, the results is not updated on the result form
I tried those 3 lines in the search button to try to requery the result form or the subform it does not work.
Forms("frmEquipSearchResults").Form.SearchResult_sub.Requery
Forms("frmEquipSearchResults").SearchResult_sub.Requery
Forms("frmEquipSearchResults").Requery
Every time I use Requery I use a different format. As per https://learn.microsoft.com/en-us/office/vba/api/Access.Form.Requery please try:
Forms!<MainFormName>!<SubFormName>.Requery
or in your case
Forms!frmEquipSearchResults!SearchResult_sub.requery
I'm creating a form in MS Access with 10 butons simulatin a numeric keypad (only the values 0..9).
I would like to change the value of a combobox control in a subform each time I click on one of these butons. The combo box control is named "projectID"
I tried this but it is not the same as pressing the same key on a keypad.
Private Sub Buton3_Click()
Call Me.frmServDedicacion_Subformulario.Form.projectID_KeyPress(51) 'Ansii code for 3
end sub
I put this procedure as keypress event in order to verifiy the combobox method is executed, and it does (msgbox is ok) but the combobox doesn't receive the KeyAscii value.
Public Sub projectID_KeyPress(KeyAscii As Integer)
MsgBox Chr(KeyAscii)
End Sub
This looks like a problem referring to a control on a sub form from the main form. I still have trouble getting this right so I use a cheat sheet:
http://access.mvps.org/access/forms/frm0031.htm
I created a main form called main and put 10 buttons named button0 - button9 on the form and I dragged a form called mysubform onto the main form to create a subform. mysubform has a textbox named projectID. Then just set the click event to button0 to:
Private Sub button0_Click()
Me!mysubform.Form!projectID = 0
End Sub
Don't forget similar click events for buttons 1-9
some things that may be helpful:
! is the bang operator see:
Bang Notation and Dot Notation in VBA and MS-Access
by default, when you drag a form to create a subform control on another form, access gives the subform control the same name as the dragged form. so here mysubform refers to the subform control and not the original form used to make the subform.
Then .Form gets the form wrapped by the subform control.
I hope this answers your question
I'm trying to implement a very simple subform document grid on a form:
I have everything except getting the file path when the user clicks the grid. How can I get the filepath value from the user row click event ?
Sorry if my terminology is off I rarely write vba
You can create a public subroutine that references your FilePath field and then reference this subroutine in the on-click event of each of the fields on your subform.
So if your subform looks like this:
Go in to Design View of the form, and select one of your fields:
With a field selected, go to the Property Sheet on the right-hand side and go to the Event tab and click the [...] button on the On Click event:
You'll be taken to the form's VBA script module and it'll create the initial VBA for the on-click event of the field you selected:
Ignore that field's on-click event VBA for now, and instead move your cursor to the top and make some room for a public subroutine above the field's on-click event.
Write something like this at the top:
Public Sub GetFilePath()
Debug.Print Me.FilePath
End Sub
So your code in Access should now look something like this:
That public sub I've called GetFilePath can now be referenced in the on-click event of every field in your subform. Let's finish the on-click event of the ID field that we just started...
...and also reference the same public sub in every other field's on-click event (again, by selecting the field in Design View and then clicking [...] button in Property Sheet's on-click event):
In the VBA editor, make sure you have the Immediate Window open; it should be in the area below your VBA code. If it's not there press Ctrl + G or go to View > Immediate Window:
With the VBA editor and Immediate Window still open, go back to your form and put it into Form View.
Click on any row and you should see the FilePath data for the row you've clicked on print out in the Immediate Window (this is what Debug.Print does):
You probably don't want the FilePath to go the Immediate Window, but as you haven't specified where you want it to go I figured this would at least illustrate how you can get at that data by clicking on a record in your subform.
All you need to do is replace the Debug.Print Me.FilePath line to whatever is useful to you.
Hope this was enough to get you started though :)
MS Access does not provide Row click event. You have to either perform, [Form onClick Event] or ideally make the filePath as HyperLink and onClicking FilePath retrieve its value.
When you go for [Form onClick event] you will get the FilePath from selected row. But the click event is only fired if you are clicking the form and none of the fields.
As above mentioned, make the FilePAth field as hyperlink, add onClick event to it and retrieve the value.
sorry for upwarming but the accepted answer is not the best way to go.
Instead of creating an OnClick-event for every column in that subform (for each control),
you should rather use the OnCurrent event of the Subform itself, which is triggered whenever you change the current record. This basically happens whenever you click on another row in the subform.
Doing so will save you work whenever you extend the subform with a new column.
in that OnCurrent Event of the Subform you will then have the same code.
Basically it should look like this:
Public Sub Form_Current()
Debug.Print Me.FilePath
End Sub
Using VB.Net (Windows Application)
I have one main form(Data entry form), i creating many form at run time.
Code for creating a multiple form at run time.
Button1 click
If IsNothing(frm) OrElse frm.IsDisposed Then
newfrm = New frmEntry
End If
newfrm.Show()
I have popup windows for selcting the value in the Data entry form.
Code for selcting the value from popup windows
Popup Window code
If e.KeyCode = Keys.Enter Then
frmEntry.txtbox1.Text = gridview1.Rows(crRow).Cells("code").Value.ToString().Trim()
End If
The above popup window code is working for Data Entry Form, but it is not working for new forms (at run time)
When i select the value from popup windows means, it is appearing in frmentry textbox, not in newfrm textbox.
Popup windows selected value should appear in current active form.
What wrong in my code.
Need VB.Net Code Help
If the form you open the popup from is what you need to change values in, have you considered passing a reference to the opening form to the popup when you open it? So that you have direct access to the form that has the controls that will need updated?
This constructor in the popup window:
Private mOpeningForm As frmEntry
Public Sub New(OpeningForm As frmEntry)
InitializeComponent()
mOpeningForm = OpeningForm
End Sub
This modified to use the reference to the form sent to the popup form:
If e.KeyCode = Keys.Enter Then
mOpeningForm.txtbox1.Text = gridview1.Rows(crRow).Cells("code").Value.ToString().Trim()
End If
This in the form when the window is being created at runTime:
If IsNothing(mEntryForm) OrElse mEntryForm.IsDisposed Then
mEntryForm= New frmEntry(me)
End If
mEntryForm.Show()
At the top level of the Data Form Class (The one creating the popups)
private mEntryForm as frmEntry
That will allow you to have a reference to the Instance of frmEntry from anywhere in the data form class. (Note that I changed the name of the popup form instance in for the button click event code too)