I have an access database that has a form that shows information about students, name, class, course etc. On the form I have a subform that shows the grades for the students. I have an edit button with this code:
If Me.AllowEdits = True Then
Me.AllowEdits = False
Me.genderCbo.Locked = True
Me.courseCbo.Locked = True
Me.subfrmGrades.Locked = True
ElseIf Me.AllowEdits = False Then
Me.AllowEdits = True
Me.genderCbo.Locked = False
Me.courseCbo.Locked = False
Me.subfrmGrades.Locked = False
End If
But with this code, whether it is is edit mode or not, I cant edit the grades in the subform. Can someone please come up with a fix? Been searching the internet for a good 30min now and couldn't find anything.
Thanks in advance
You have to reference the Form object within the subform control. To do this use me.subfrmGrades.Form.Allowedits=true instead of just me.subfrmGrades.Allowedits=true.
Related
I've been learning today some VBA basics to apply in powerpoint, but I have some experience in some other languages. As title says, I want a picture to be shown after I click on 3 other pictures before that. When any of this 3 pictures are clicked, they trigger a tick to be shown above that image, and I'm using those as a refer to code my macro. I have the following:
Sub Condicion()
Set Diapo14 = ActivePresentation.Slides(14)
If Diapo14.Shapes("tick1").Visible = True And _
Diapo14.Shapes("tick2").Visible = True And _
Diapo14.Shapes("tick3").Visible = True Then
Diapo14.Shapes("FlechaDer").Visible = True
End If
End Sub
I have the picture I want to show (FlechaDer) with a disappear effect as soon as the slide starts, but no matter what I do, when I test the slide, the picture is always there. Maybe I'm not applying the correct approach, hope someone can help me. I'm not even sure if this can be done in PowerPoint.
I got it working with the code below. I had to replace the "ticks" in the If cycle, and instead of them I used the pictures that once clicked popped up the ticks:
Sub Can12()
Set Diapo12 = ActivePresentation.Slides(12)
Diapo12.Shapes("Can").Visible = False
If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
Diapo12.Shapes("FlechaDer").Visible = True
End If
End Sub
Sub Wool12()
Set Diapo12 = ActivePresentation.Slides(12)
Diapo12.Shapes("Wool").Visible = False
If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
Diapo12.Shapes("FlechaDer").Visible = True
End If
End Sub
Sub Pencil12()
Set Diapo12 = ActivePresentation.Slides(12)
Diapo12.Shapes("Pencil").Visible = False
If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
Diapo12.Shapes("FlechaDer").Visible = True
End If
End Sub
It worked fine on activating an animation (Right Arrow popping up) when all 3 items were clicked. I had to add the corresponding macro to the picture. (Can, wool and pencil)
I'm trying to make a button to lock/unlock edits and adittions in a form and subform.
In my main form CONSULTAS PEDIDOS, I have two subforms CONSULTAS PRODUCTOS y LOTES. When I click on BLOQUEAR button, I want to turn on/off AllowEdits and AllowAditions properties in CONSULTAS PEDIDOS and CONSULTAS PRODUCTOS depending on the caption text, but I want keep editing and adding records in LOTES subform.
I tried this code:
Private Sub bloquear_Click()
With Me.bloquear
If .Caption = "Unlock" Then
Me.AllowAdditions = True
Me.AllowEdits = True
Me.CONSULTA_PRODUCTOS.AllowAdditions = True
Me.CONSULTA_PRODUCTOS.AllowEdits = True
.Caption = "Lock"
Else
Me.AllowAdditions = False
Me.AllowEdits = False
Me.CONSULTA_PRODUCTOS.AllowAdditions = False
Me.CONSULTA_PRODUCTOS.AllowEdits = False
.Caption = "Unlock"
Me.Refresh
End If
End With
End Sub
I tried the code only with main form CONSULTAS PEDIDOS and it works, but when I added CONSULTA PRODUCTOS clauses, Access reports me The expression On Load you entered as the event property setting produced the following error: Method or data member not found. I don't know what I'm doing wrong. I'm a absolute beginner writing code.
Thanks in advance.
Need to follow subform container control name with reference to Form class because those are properties of form object, not container control.
Me.CONSULTA_PRODUCTOS.Form.AllowAdditions = False
Me.CONSULTA_PRODUCTOS.Form.AllowEdits = False
I have a form named as NoForm which has two List-boxes named as No_ListBox1 and No_ListBox4.
By Default, the Property of No_ListBox4 is set to be enabled = false
when No_ListBox1 value is "yes", , the Property of No_ListBox4 is set to be enabled = true
When it is "No", it stays as enabled = false. But here comes the Problem, I am not able to deselect the selected values in No_ListBox4 when the user changes it back to "No" in No_ListBox1.
Kindly Share your thoughts.
But,
This is the Code,
Private Sub No_ListBox1_Click()
SelectNext = NoForm.No_ListBox1.Value
If SelectNext = "Yes" Then
NoForm.No_ListBox4.Enabled = True
End If
If SelectNext = "No" Then
NoForm.No_ListBox4.Enabled = False
If NoForm.No_ListBox4.Selected = True Then
NoForm.No_ListBox4.Selected = False
End If
End If
Try this:
Private Sub No_ListBox1_Click()
With Me
If .No_ListBox1.Value = "Yes" Then
.No_ListBox4.Enabled = True
Else
With .No_ListBox4
.Selected(.ListIndex) = False
.Enabled = False
End With
End If
End With
End Sub
The solution is to flip your logic around. Deselect the items first, then disable the control.
I was wondering if you guys can help me with this problem. So I want a button that would show/hide a table in ms word. However, I can only get the button to do either show or hide separately with my code. Currently this code will show my table:
Sub Loan1()
'Hides Sections Not Used in Expanded Form
Dim CollapseRange1 As Range
'Set Which Range/Cell to Associate with Button
With ActiveDocument.Tables(3)
Set CollapseRange1 = .Rows(1).Range
CollapseRange1.End = .Rows(25).Range.End
End With
'If button is pressed then Hide/show CollapseRanges
If CommandButton1 = False And CollapseRange1.Font.Hidden = False Then
CollapseRange1.Font.Hidden = True
Else
CollapseRange1.Font.Hidden = False
End If
End Sub
I was hoping to be able to use one button to show and hide my table depending on the state of my table (hidden or unhidden)
Any help would be appreciated!
OH I managed to figure out my questions. Instead of
If CommandButton1 = False And CollapseRange1.Font.Hidden = False Then
I use
If CommandButton1 = False And ActiveDocument.Tables(3).Cell(1, 1).Range.Font.Hidden = False Then
I hoped this helps someone else!
I am creating a data entry form for one of my database tables. For one of the sections, I have the text field with ONLY the caption: "Description 1" showing. If the Description 1 textbox is filled out by the user, I want it to show the Description 2 textbox. If the user fills out the Description 2 textbox, the Description 3 textbox will show up and so on up to 10 Description textboxes. Is there a way to hide the extra text boxes kind of like when you fill out the information while creating a macro? For example when you click Create --> Macro, there is only a dropdown box for you to select an action. If you choose Open Form and hit enter, 6 more text boxes with captions appear.
Is there a way to get that kind of functionality in a form? Also, in the Macro builder, it dynamically rearranges the page for you, can this also be done with the form?
Follow these steps:
Mark the visible property as false
Add OnChange event for each textbox.
Write the VBA code to determine if the next control will be showed or hide. Note, the Me!FormControlItem.Text is accessible only if the control is focused.
There is the 3 functions for each control.
Private Sub text1_Change()
If Not Trim(Me!text1.Text) = "" Then
Me!Text2.Visible = True
Me!Label2.Visible = True
ElseIf Not Trim(Me!Text2) = "" Then
Me!Text2.Visible = True
Me!Label2.Visible = True
Else
Me!Text2.Visible = False
Me!Label2.Visible = False
End If
End Sub
Private Sub Text2_Change()
If Not Trim(Me!Text2.Text) = "" Then
Me!Text3.Visible = True
Me!Label3.Visible = True
ElseIf Not Trim(Me!Text3) = "" Then
Me!Text3.Visible = True
Me!Label3.Visible = True
Else
Me!Text3.Visible = False
Me!Label3.Visible = False
End If
End Sub
Private Sub Text3_Change()
If Not Trim(Me!Text3.Text) = "" Then
Me!Text4.Visible = True
Me!Label4.Visible = True
ElseIf Not Trim(Me!Text4) = "" Then
Me!Text4.Visible = True
Me!Label4.Visible = True
Else
Me!Text4.Visible = False
Me!Label4.Visible = False
End If
End Sub
Enjoy!