General :: Using Combobox Selection In IF Statement To Make Another Text Box Visible
Aug 28, 2012
I have a combobox [CBreason] that reads from a table to show me why someone is gaining access to the building.
One of the options is "Incident".
When incident is selected I want a textbox [TBIncidentNo] and a button[BIncidentDup] control I made to appear.
I thought that the code:
If Me.CBReason.Value = "Incident" Then
Me.CBIncidentNo.Visible = True
Me.BIncidentDup.Visible = True
Else
Me.CBIncidentNo.Visible = False
Me.BIncidentDup.Visible = False
End If
Placed in the after update action of the CBReason box would sufice but it doesnt work
I'm guessing the value is not recognised fro some reason but i cant work out why. There is no error message or issus, it makes the box dissapear when there is no entry but no change for selecting incident.
I have a form where i select via a combo box if a product has been inspected, if it has, additional controls are then made visible.
If Me.Inspection_Completed = "Yes" Then Me.Date_Inspection_Comp.Visible = True Me.Date_Inspection_Comp = Me.Dateinsp Me.Inspector.Visible = True Me.Qty_Inspected.Visible = True Me.OK.Visible = True
[Code] ....
I tried to put this in a function so i could call it on load, or on current etc, but cant seem to get it to work, apparently you cannot use the me. in a function.
Hi, I have a form with a INFO button, what I need is when the info button is pressed a text box becomes visible on the form and when pressed again the text box become not visible, this will allow the final user the have additional information regading compiling the form etc! Thanks Marco
Hi, Is it possible when choosing a combo box to have it make a text box visible, when in this text boxes properties you've chosen visible=NO. Can an event procedure or some code be written that will make visible=YES.
Hi, Is it possible when choosing a combo box to have it make a text box visible, when in this text boxes properties you've chosen visible=NO. Can an event procedure or some code be written that will make visible=YES.
I have a report that displays on a continuous style report. What courses the employee have been on and when they expire
right I have field call expirydate and another call dayover showing the number of days till that course has expired also I have made a label called Expired1
now what I'm trying to do.....
if the expirydate has passed I want the expired1 label to be visible and dayover field to become invisible
I have tried
Code: Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If Me.Expirydate < Date Then Me.expired1.Visible = True Me.DaysOver.Visible = False End If If Me.Expirydate > Date Then Me.expired1.Value = False Me.DaysOver.Value = True End If
I have also tried the code on current event on the report
now my problem if one of the course has expired it will show the label called Expired1 but on all the records but I only want it to display on the record that has expired and leave the daysover text box visible if course has not expired
Okay then, after much trouble and confusion, I finally realized I need to use an Extended listbox in order to allow for multiple items to be selected from a list on my form (rather than the evil multiple selection combobox!).
However, now I am trying to figure out how to make one listbox (IndustryClassification) only be visible if the item "Industry" is selected in another listbox (TypeOfBusiness). Coding I can use for this in the AfterUpdate event of the listbox?
I have a combobox on my form called TypeOfBusiness, with fields including Corporation, Education, Industry, Non-Profit. In order to make a second combobox called IndustryClassification appear when Industry is selected from the TypeOfBusiness combobox, I have used the following code:
Code: Private Sub Form_Current() If Me.TypeOfBusiness = "Industry" Then Me.IndustryClassification.Visible = True Else Me.IndustryClassification.Visible = False
[Code] .....
It works just fine. However, when a user selects both, say, Industry and Education, the IndustryClassification combobox will not appear. What code I can use to ensure the IndustryClassification box will appear regardless if another box is checked in addition to Industry? I am wondering if it has to do with the Column attribute.
I have a form based on a query.On the form I have 4 comboboxes.The combo boxes filter eachother without a problem (based on custom select query).Now I want after the fourth combobox value is selected, I want to populate a text field with a value from a different column from the master query (after the 4 selections only 1 value should be possible)I try to say this easy.Master query contains 5 columns:
- group - type - job - insurance - charge
combo1 selects group (and filters records) combo2 selects type (from remaining records and filters again) combo3 selects job (from remaining records and filters again) combo4 selects insurance (from remaining records and filters again)
[code]....
This works great and the dropbox only shows 1 OF EACH DIFFERENT record...If I add a text box and want to see the "charge" value, that I thought I could use the ME.text-code. But in order to do this, I have to add the charge column into the query of Combo4.the dropbox for insurance gives me multiple values that are the same. Is there any way to make this work?
I have a Main Form with a Sub-Form, the sub-form is base off a query. on the sub-form i have 8 controls, one of them is "Status' and "Process" and "Review" My Main Form have a Refresh command that refreshes the data in the sub-form.
What i am trying to do is make the "Process" Control only visible is "Status" is a certain status and "Review" visible if "Status" is something else. what i have done works correctly On Open. I run into and issue on the refresh command. I get Run-time error '2165' "You can't hide a control that has the focus"
Code: If Forms!Main_Form.[Name subform]!Status = "Ready" Then Forms!Main_Form.[Name subform]!Process.Visible = True Forms!Main_Form.[Name subform]!Review.Visible = False ElseIf Forms!Main_Form.[Name subform]!Status = "Reviewing" Then Forms!Main_Form.[Name subform]!Review.Visible = True Forms!Main_Form.[Name subform]!Process.Visible = False End If
I have done similar with a main form and making sub-form visible or not based on a control on a main form and that has worked perfectly. I am not sure how the control is getting focus and cause the error.
I have a combobox on an unbound form. After making a selection, I click a command button which opens a bound form to a new record. What I need to code next or add into the macro, is for the selection of the combobox to fill in the contact id, and contact name in the correct text boxes.
The combobox row source is: SELECT qryPBS.ConID, qryPBS.PBSName FROM qryPBS; bound column 1.
I have a table customers, which i can select from an combobox. In my form two tables are bound. one is the customers, and the other is a table where i want to copy the customer information.
I tried this code to copy the selection I made in the combobox afterupdate.
[T_Invoice_firstname] = [T_customer.firstname]
But I get an error 2448 saying I cant assign a value to this object.
I tried msgbox [T_customer.firstname] and i see the name
I tried msgbox [T_invoice.firstname] and i see the empty record
I even filled in a name in the t_invoice.firstname and it shows with the msgbox also.
I have a table of raw materials that have two fields, their stock code and longer description.
I have another table that is tracking the usage of these materials. I want both the stock code and longer description to be recorded in the usage table.
I want the "Description" field in the usage table form to auto populate when the user selects the corresponding stockcode from a combobox.
When i click a button on the main form the vba code will execute and get the value from the combobox ie TE4700 and locate the macro with the same name ie TE4700 with reports in then it will run the macro and print off the reports.
When loading a form often some of the text is missing, headers are not there and/or the colours for the background are simple white, until I either resize the form or scroll up and down a few times.
I am designing a nomination form (web database so no vba macros can be used).
The form has 3 combo boxes: cboStaffName, cboLevel, cboNominee.
The form is bound to the tblSubmit table where the submissions are populated.
I used a select statement:SELECT Staff_List.Staff_Name FROM Staff_List; to populate the combo box for the Staff Name selection.
This is the select statement to populate the job level combobox:
SELECT Staff_List.Level, Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Staff_Name)=[forms]![frmtest]![cboStaffName]));
The select statement to populate the combobox for the nominee combobox:
SELECT Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Level)=[forms]![frmtest]![cboLevel]));
The problem is that the staff_name in the first combobox is still found in the nominee combobox which should not be because a staff cannot nominate self. There is a field in the Staff_List called YesNo that should be activated for each staff that is selected so that the select statement on the nominee combobox can be updated accordingly to remove items with the field "Active"
How to get the checkbox selected for each corresponding staff.
I have 2 comboboxes, the first one is called "activity", whereby I have 3 options to choose from, and the second is called "level".
When I click an "activity", for example Drawings, I want the "level" combobox to list a unique set of options for that category. and if I click on a different "activity" for example Planning, I want the "level" combobox to show a completely different set of options.
If anyone can give me any help on how to do this then I would be very grateful!!
In the database attached I have a form called from Candidates.In this form is a combo box where a user can select what company the candidate belongs too.
However some candidates are Private Individuals (do not belong to a company).Therefore, I want the Position field to be set to 'n/a" by default if 'Private Individual' is selected.
I am trying to populate multiple text boxes from combo box using one table. First text box is getting populate on base of combo box value while 2nd text box is not getting populating.
I have used the following to populate the text boxes, even row count is correct, But why is not 2nd text box is not populating ?
=[Combo2].[Column](1) =[Combo2].[Column](2)
One thing I noted when I provide the control source then selection gets stop from combo box...I am giving the valid control source is customerID but its not working.Could it be the reason ? Why selection gets stop from combo box when provide the control source ? If remove the control source then 1st text box is getting filled on basis of combo selection and 2nd text box value is not getting filled as describe above.
hey guys i was just wondering if anyone knew the code to make a table visible via changing a combo box. i know for a form its simply Form_formname.visible=True
i am trying to make my tab control visible, after i did it visible=false in the open form event. the problem is that the button that supposed to open the tab control is locates in a form and the tab control is located as a sub form. it doesnt recognize any version of writing that i am trying.
details: main form - "f_1" sub form - "f_2" the btn - btn1 (located in the main form) the tabctl - tblctrl1 (located in the sub form)
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is frmTrialInfo. Each Trial can have three Classes. The third form is frmClassInfo. These forms are used for update and adding new records.
The user displays an event for update (frmEventAdd). Then clicks on a button to display the Trials for that event (opens frmTrialInfo). frmTrialInfo displays information for one Trial at a time. The user clicks on a button to display class information for that trial (frmClassInfo).
One of the fields on frmClassInfo is called cboJudge. It's a combobox with names of Judges (judges of dog competitions). The judge information in the combobox comes from two tables: tblPeople and tblJudges. If the user wants to add a new judge they may click on the btnNewJudge. btnNewJudge will open a form that is used to add a new person (frmPeople).
Because frmPeople is opened from many different points in the application, I found it easier to simply make the three, already opened, forms INVISIBLE. So...command button btnNewJudge opens frmPeople and makes frmEventAdd, frmTrialInfo, and frmClassInfo INVISIBLE.
When frmPeople is closed (btnClose), it checks to see if each of the previously opened/visible windows is open and then makes each VISIBLE, again. frmEventAdd and frmTrialInfo reappear just fine. However frmClassInfo does not.
I have traced the btnClose_Click routine in frmPeople and it certainly looks like every line of code is being hit, but the line that should make frmClassInfo visible does not do anything (nor does it generate any error).
Here is the code from btnClose_Click in frmPeople. Can you help me?
********************************************
Private Sub btnClose_Click() On Error GoTo Err_btnClose_Click
Dim blnEventAdd_Open As Boolean Dim blnTrialInfo_Open As Boolean Dim blnClassInfo_Open As Boolean
blnSecondChance = False
If blnDataChanged = True Then If DataHasChanged() = vbYes Then Call btnSave_Click End If End If
'================================================= ======================================= 'blnSecondChance=False = NO SECOND CHANCE ... Close this Form 'blnSecondChance=True = USER GETS A SECOND CHANCE ... Do NOT Close this Form '================================================= ======================================= If blnSecondChance = False Then 'Zero out Relative Record Number from Array svRecNo(intCallerIX) = 0 blnDoUpdate = False blnDataChanged = False DoCmd.Close acForm, Me.Name
'Is the frmEventAdd form open? blnEventAdd_Open = SysCmd(acSysCmdGetObjectState, acForm, "frmEventAdd") And _ acObjStateOpen
'Is the frmTrialInfo form open? blnTrialInfo_Open = SysCmd(acSysCmdGetObjectState, acForm, "frmTrialInfo") And _ acObjStateOpen
'Is the frmClassInfo form open? blnClassInfo_Open = SysCmd(acSysCmdGetObjectState, acForm, "frmClassInfo") And _ acObjStateOpen
If blnEventAdd_Open Or blnTrialInfo_Open Or blnClassInfo_Open Then If blnEventAdd_Open Then Forms("frmEventAdd").Visible = True Forms("frmEventAdd")!cboContact.Requery Forms("frmEventAdd")!cboSecretary.Requery End If
If blnTrialInfo_Open Then Forms("frmTrialInfo").Visible = True Forms("frmTrialInfo")!cboTrialRep.Requery End If
If blnClassInfo_Open Then Forms("frmClassInfo").Visible = True Forms("frmClassInfo")!cboJudge.Requery End If
intCallerIX = intCallerIX - 1 Else DoCmd.OpenForm PopCaller(), acNormal End If End If
I have orders being entered, some of which may be in any one of several categories for which we need additional information. I would like to be able to have either a set of checkboxes answering the question "Check the appropriate box if the order is one of the following types" ... or ... have a radio-button selection where only one can be chosen at a time. That is important... that only one be able to be chosen at a time. It is possible to have orders outside this set of choices, and no selection made at all. Once the selection is made, I'd like either the appropriate fields to show in the main form... or ... have the appropriate subform show based on the entry from the checkboxes or radio selection.
I could have
OrderEntryForm containing checkboxes or radio selection for Type1, Type2, Type3 with the appropriate Type1fields, Type2fields, and Type3fields hidden until the right checkbox or radio button is selected.
or
OrderEntryForm containing checkboxes or radio selection for Type1, Type2, Type3 with the appropriate subforms Type1form, Type2form, and Type3form hidden until the right checkbox or radio button is selected.
There's only one problem: I have no idea how to make this happen... nor which way of doing this is best. Any help is GREATLY appreciated.