I am working in Access. I have a form that users select a "method" in the form of a radio button from a list. Depending on what they select, entry fields will populate. Recently we have moved to a tab control to store all of these fields.
My question is:
How do I make a certain tab show automatically when clicking on the corresponding radio button?
The fields on the corresponding tab populate but the form doesn't automatically switch to show that tab.
Thanks!
Here is the first case. In this case, the visible fields do populate when the corresponding radio button is selected. HOWEVER, the tab where these fields are stored does not automatically display. Just the first tab/page shows. I have to click on the correct tab/page to see the fields. I want the Tab/page to automatically display.
Private Sub frmMethodOptions_AfterUpdate()
Select Case Me.frmMethodOptions.Value
Case 1
'International Fields
lblInternational.Visible = False
lblBeneBankHeader.Visible = False
Intl_BeneBankType.Visible = False
Intl_BeneBankID.Visible = False
Intl_BeneBankName.Visible = False
Intl_BeneBankCode.Visible = False
lblRecBankHeader.Visible = False
Intl_RecBankType.Visible = False
Intl_RecBankID.Visible = False
Intl_RecBankName.Visible = False
lblBeneInfoHeader.Visible = False
Intl_BeneInfoAcctNumber.Visible = False
Intl_BeneInfoAcctName.Visible = False
Intl_BeneInfoChargeParty.Visible = False
'Wire Fields
lblWireInformation.Visible = True
BeneABA.Visible = True
BeneBankName.Visible = True
BeneAcctNumber.Visible = True
BeneAcctName.Visible = True
RepetitiveCode.Visible = True
'Common Fields
OBI.Visible = True
DebitAccount.Visible = True
'Setting the method
txtMethod.Value = 5
txtMethodName = "Domestic Wire"
Instead of leaving all tab/pages open, I simply made all other tabs invisible. For instance, if I had two tabs and clicked the international radio button, I would want only the international tab/page to show. By setting ONLY the tab you want to visible, you get all of the necessary fields to show and they are ready for user input.
tabMain_Intl.Visible = True
tabMain_Dom.Visible = False
Related
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!
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.
I am coding a basic program that allows users to calculate useful data on a shape (2d and 3d) based on information such as radius length, side length, height, etc.
I would like to create a settings MENU that allows users to set how many decimal places they would like the answer to go to, so what I did was
Private Sub btnSettings_Click(sender As Object, e As EventArgs) Handles btnSettings.Click
If btnSettings.Text = "Settings" Then
btnSettings.Text = "Back"
ElseIf btnSettings.Text = "Back" Then
btnSettings.Text = "Settings"
End If
Do While btnSettings.Text = "Back"
'makes IO elements invisible
lblEnter.Visible = False
lblEnter2.Visible = False
lblData1.Visible = False
lblData2.Visible = False
lblData3.Visible = False
lblAnswer1.Visible = False
lblAnswer2.Visible = False
lblAnswer3.Visible = False
txtEnter.Visible = False
txtEnter2.Visible = False
btnClearTxt1.Visible = False
lblEnter3.Visible = False
txtEnter3.Visible = False
chkBox.Visible = False
btnCalculate.Visible = False
btnClear.Visible = False
'Makes shape selection elements invisible
picCircle.Visible = False
picSquare.Visible = False
picTriangle.Visible = False
rdoCircle.Visible = False
rdoSquare.Visible = False
rdoTriangle.Visible = False
btn3D.Visible = False
'Changes texts on necessary elements
lblSelectShape.Text = "Settings"
Loop
End Sub
As you can see, when "btnSettings" shows the text "Settings", the elements on the screen are VISIBLE to the user, however as soon as "btnSettings" changes text to "Back" (indicating the user is inside the settings menu) all the elements on the screen disappear, making room for the elements the settings menu will have. However, while debugging the program whenever I hit the settings button the program crashes.
Any help? Thanks
Use a Select Case for this:
Select Case shapeType
Case shapeType.Circle
'logic for this
'...
End Select
I'm new at VBA so sorry in advance if this is a silly question. I have a Worksheet with ActiveX List boxes. The worksheet also has Toggle Switches. The toggle switches are set up to Hide Rows and ActiveX boxes when not depressed and Show Rows and ActiveX boxes when depressed. I'd like to save the file with all of the Toggle switches not depressed so that the user can un-hide only the rows and boxes that they need. Everything works properly until I save the file with all rows hidden. After the save all of the boxes change locations. I've tried setting the boxes to "Move and Size with cell", "Move but don't size with cell", and "Don't more or Size with cell" in the preferences. The same thing happens with all options. Below is my toggle switch code. Is there something in there causing this to happen?
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
'This area contains the things you want to happen
'when the toggle button is not depressed
Range("101:183").EntireRow.Hidden = False
Sheet1.Range("94:144").EntireRow.Hidden = False
'This hides the listboxes since they can not move and
'size with cells
Sheet11.OLEObjects("ListBox1").Visible = True
Sheet11.OLEObjects("ListBox2").Visible = True
Sheet11.OLEObjects("ListBox3").Visible = True
Sheet11.OLEObjects("ListBox4").Visible = True
Sheet11.OLEObjects("ListBox5").Visible = True
Sheet11.OLEObjects("ListBox6").Visible = True
Sheet11.OLEObjects("ListBox7").Visible = True
Sheet11.OLEObjects("ListBox8").Visible = True
Sheet11.OLEObjects("ListBox9").Visible = True
Sheet11.OLEObjects("ListBox10").Visible = True
Sheet11.OLEObjects("ListBox11").Visible = True
Sheet11.OLEObjects("ListBox12").Visible = True
Sheet11.OLEObjects("ListBox13").Visible = True
Sheet11.OLEObjects("ListBox14").Visible = True
Sheet11.OLEObjects("ListBox15").Visible = True
Sheet11.OLEObjects("ListBox16").Visible = True
Sheet11.OLEObjects("ListBox17").Visible = True
Sheet11.OLEObjects("ListBox18").Visible = True
Else
'This area contains the things you want to happen
'when the toggle button is depressed
Range("101:183").EntireRow.Hidden = True
Sheet1.Range("94:144").EntireRow.Hidden = True
Sheet11.OLEObjects("ListBox1").Visible = False
Sheet11.OLEObjects("ListBox2").Visible = False
Sheet11.OLEObjects("ListBox3").Visible = False
Sheet11.OLEObjects("ListBox4").Visible = False
Sheet11.OLEObjects("ListBox5").Visible = False
Sheet11.OLEObjects("ListBox6").Visible = False
Sheet11.OLEObjects("ListBox7").Visible = False
Sheet11.OLEObjects("ListBox8").Visible = False
Sheet11.OLEObjects("ListBox9").Visible = False
Sheet11.OLEObjects("ListBox10").Visible = False
Sheet11.OLEObjects("ListBox11").Visible = False
Sheet11.OLEObjects("ListBox12").Visible = False
Sheet11.OLEObjects("ListBox13").Visible = False
Sheet11.OLEObjects("ListBox14").Visible = False
Sheet11.OLEObjects("ListBox15").Visible = False
Sheet11.OLEObjects("ListBox16").Visible = False
Sheet11.OLEObjects("ListBox17").Visible = False
Sheet11.OLEObjects("ListBox18").Visible = False
End If
End Sub
I know this isn't the answer to your question (I haven't even looked at it yet), but i just felt like giving you this code, this is the exact code you provided and will function the same way, just looks a tiny bit clearer (actually as it also removes the if statement it prolly even performs at like 1/1000000 of a millisecond faster also =D)
Private Sub ToggleButton1_Click()
Dim boolToggleValue As Boolean
Dim i As Integer
boolToggleValue = ToggleButton1.Value
'This area contains the things you want to happen
'when the toggle button is not depressed
Range("101:183").EntireRow.Hidden = Not boolToggleValue
Sheet1.Range("94:144").EntireRow.Hidden = Not boolToggleValue
'This hides the listboxes since they can not move and
'size with cells
With Sheet11
For i = 1 To 18
.OLEObjects("ListBox" & i).Visible = boolToggleValue
Next i
End With
End Sub