Modules & VBA :: Display / Hide Subforms Based On Yes / No Field In The Form
Oct 4, 2013
I have created a form with 3 subforms on. i was just wondering is it possible to display/ hide these subforms based on a Yes/No field in the form. as the subforms would only be valid if the field is ticked as yes.
I have a lengthy CASE statement in my database that displays specific text in a field based on the value of another. Simple stuff but for some reason it randomly will not work on certain values, and never the same one twice. Is there a commonly known cause for this? I have verified that the spelling and spacing etc. are correct in my code so that shouldn't be causing the problem.
My form has a listbox (lstHeatTreatments - Multi-Select disabled) that displays Heat Treatment descriptions and an unbound textbox (txtHTDetails) that I would like to have display the corresponding memo field when a description is selected from the listbox.
This is my code so far:
Code: Private Sub lstHeatTreatments_AfterUpdate() Dim myConnection As ADODB.Connection Dim myRecordSet As New ADODB.Recordset Dim mySQL As String Dim selectedRequirementKey As Long Set myConnection = CurrentProject.AccessConnection Set myRecordSet.ActiveConnection = myConnection
I have a searchable form that display information on agreements other companies have with us. If a company requests an inspection we have 30 days to go out and complete it.
I am trying to create a message box that will display all inspections that are due within 5 days when the form loads. No luck so far, only broken dreams.
Is it possible for message boxes to use expressions and display information that fits the criteria?
I recall using a database (created by someone else that I don't have contact with) whereby, when you open it, the user-end form opens up on your Windows desktop, but the usual MS Access window is minised/hidden.
Using Access 2010. Fairly new to automation and macros.I have two tables (tblProductReceived and tblBins) and a form (frmProductReceived).A field in tblBins corresponds to a location the bin is at (named BinLocationID) and the tblProductReceived table tracks product that a specific bin has received.
What I need is for the tblProductReceived field PRLocationID ([tblProductReceived].[PRLocationID]) to be automatically populated with where the bin is at ([tblBins].[BinLocationID]) when selecting a specific bin in the form (frmProductReceived).
I'm trying to lock certain fields on my form based on the value in a particular field. It seems to work the first time but applies itself to all other records in the database from then on!
The starting point is a command button that sends an email and makes Me.DPLLock = 1. The corresponding table entry is formatted as a number.
The code is...
Private Sub Form_Current() If Me.DPLLock = 1 Then Me.OR_Name.Locked = True Me.OR_Sales_Order.Locked = True Me.OR_WO_No.Locked = True Me.OR_Qty.Locked = True
I have a form that has a drop down box with all of my project numbers in it. when I choose a project number, I can then choose from several report buttons on that same page that opens a report just showing that projects info (easy enough). I then have different report buttons that open those same reports, but showing every project (no filter).
The reports have a cover page that has the field, 'project number' in the front, so when a particular project is chosen from the drop down, that project number will show on the cover page (still pretty easy).
My question is, when I open the full report(no filter), is there a way to tell the report not to show the 'project number' field? since the full reports show every project, the 'project number' field will show the first project number, which is not what I want to do.
I have a query with a Date field for EndDate (the dates for end-of-week, Fridays in our case) and another field for Sales (number of sales, not dollars).I want to add 4 calculated fields that represent weeks and have the Sales appear in the correct column (field) for that date.So I will have columns for 10 July 15, 17 July 15, 24 July 15 and 31 July 15 and I want the Sales for each record to land in the correct date column, based on the EndDate column. (The 4 fields is just for the sake of the example, I will actually be having dozens of these calculated date fields).I tried to do it by setting up the 4 calculated fields like:
10Jul15: Sales and then adding Criteria like: EndDate = #10/07/2015# It doesnt work.
I have a continuous subform recording the information of various wireless products for an employee embedded in an employee main form. Please see screen shot enclosed.
There is a check box "BYOD/Personal" on the subform. I want to hide a number fields when this check box on independent record is checked. However, if I use the following codes, the changes apply to all records under that employee.
Private Sub BYOD/Personal_AfterUpdate()
If BYOD/Personal.Value = True then Me.Provider.Enabled = False Me.XXX.Enabled = False....etc. Else Me.Provider.Enabled = True Me.XXX.Enabled = True....etc. End If End Sub
How can I just disable those fields on the subform of a specific record when the BYOD/Personal field for that record is checked?
I have code that I want to cycle through several fields and check instead of coding for each individual field. I thought this might worked on an earlier project but Im lost. When I try to add my code in the "If MyControls Then", I want it to hide the field on a report if it is blank. It doesnt allow me to do MyControls.Visible.
Code: If Len(Reports!RecallReport!QAW1 & vbnullsting) = 0 Then Reports!RecallReport!QAW1.Visible = False End If
but I want the below code to go through each field With QAW in it and hide it if it is blank.Or having it go through each field individual. There are 10 Fields With QAW THen there are another 10 fiels with ShipDist. I would prefer a simple solution to check all at once.
Code: Dim MyControls As Control For Each MyControls In Me.Controls ' Iterate through each element. If InStr(1, MyControls.Name, "QAW") Then If MyControls Then End If End If Next
I don't even know if I am on the right track or what.
I am working on a database. I created a list box (ListBox) that filters record for a form. This list box is controlled by another field (SearchBox) where I type search string.
The ListBox visibility is hidden when the form loads. It only becomes visible when the user starts to type in the SearchBox. The records gets filtered and when the user clicks on the selection, the form goes to the record and the ListBox becomes hidden again. All this works fine. My problem is for some technical reasons I want the ListBox to show only when there is character in the the SearchBox. When I try to type in the SearchBox the ListBox shows but when I try to clear the SearchBox with backspace the ListBox is still visible
I tried:
Code: If me.SearchBox = Null Then me.ListBox.Visible = False Else me.ListBox.Visible = True
I also tried
Code: If IsNull (SearchBox) Then
Still when I type backspace the ListBox remains visible.
EDIT: I forgot to mention that I put this code on the current event of the SearchBox Field.
I am trying to show an image on a form based on a user choice from a drop down box. For example, the user needs to choose a priority for a task. If the user chooses "Immediate" I want an image of an exclamation point to show up to draw attention that this is important.
I would like to have 3 buttons on a form. When clicking Button1, Button2 and Button3 should be shown and Button1 hidden. When clicking Button3, Button2 and Button3 should be hidden and Button1 shown.
How can I do this when it is not possible to manage the object being clicked? I tried the following which did not work because of managing an object clicked is not allowed.
I am looking to generate a total number of a given column based on two criteria.I would like a label (or textbox if necessary) to display a given total of "Active" devices based on a given month.The table name is "Blackberry" and the specific columns I would like to check would be "Activated?" and "Registration Date". I'm not sure if I should be using a dsum or dcount and the error i keep getting is a type mismatch.an active device would have the text value of "Yes.
Dim advalue As Integer advalue = DCount("[Activated?]", "Blackberry", "[Activated?]=yes" And "[Registration Date] > #01/01/2000#") lblad.Caption = advalue
I have a piece of code that I'm using to display an image on a report based on a path saved to each record. the code is:
Code: Option Compare Database Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If IsNull(Me.ImagePath) Then Me.ImgPic.Picture = "O:BellinghamIntranetProductionLabelsNo Label.bmp" Else Me.ImgPic.Picture = Me.ImagePath End If End Sub
It seems like every few months the code crashes access and then never works again. When I debug, the part that is highlighted is:
Code: Me.ImgPic.Picture = Me.ImagePath
The only way i've found to correct it is to delete the report and the module and copy them back in from a backup database. What could be causing this code to crash or how to stabalize my database to prevent this from happening again.
Can you have a hidden field in a form? Trying to set up an order process system where I need to take a wholesale price of an item then mark it up (behind the scenes) and display only the customer price. How can I accomplish this.
I have three nested forms that is Form3 is withing Form2 that is within Form1 (in reality = 1 Form and 2 subforms cascaded).
I want to select a value from Combo1, that will further brings the values in Form2, and then further filter the values in Form3. If the three combos were on the same form, I wouldn't have an issue. But since each combo is in every cascading form/subform, I dont know how to pass the filterning further to the other two combos.
I need to hide my subform on load or open of the main form but am experiencing some weird results. I have tried putting Me.SubForm.Form.Visible = False in both the on open and the on load of the main form and it works only if the tables on which the subform have records in them. If the tables for the subforms are empty I get an error 2467 telling me that "The expression you entered refers to an object that is closed or doesn't exist." I find this strange because from all I can find the subform loads first.
How can I hide the subform when the main form opens no matter what records exist or don't?
I have a data base that when first opened a login form I created pops up. I am trying to set it up so that when it opens you do not see the navigation pane. once logged in though I do want to have access to that again. I have found other VBA code online but nothing that lets me remove the navigation pane from that first form alone. I have it set so that the Ribbon is not shown when the form opens but does show once a user is logged in.
for the ribbon I used:
DoCmd.ShowToolbar "Ribbon", acToolbarNo
I thought I remembered a while ago reading a code like that for the navigation but not saving it because I did not think it would be needed (I am very new to Access) But now I cannot find it.
I have a continuous subform which queries a table of attachments. I'm using Access 2007 but not using the Attachment datatype; this DB will grow considerably and I don't want to waste precious space by filling it with bulky files. So instead, I have code which makes a copy of the attachment and adds the hyperlink (to the copy) to the table instead.
Now - I want to add a control to the subform to display an icon / image reflecting the file type of the attachment (Word doc, Excel s/s, PDF etc.)
But not sure how to go about it.
I was thinking I could use FileSystemObject.GetFileExtension at the point in the code where the attachment is added, and add a new field to my attachments table (i.e. translate "*.xls*" to "Excel", etc.) Then store / embed a handful of images for the core types I would expect and use an image control on the subform to display the image based on the value of that field.
But is that even possible / feasible?
Or, is there a handy API which can retrieve the icon associated with a file type based on what has been installed on the local machine (even if there is, there's still the problem of setting up the image control to display the appropriate icon specific to each record...)
Or, is there another control available which would be better suited to something like this than an Image control?
I have a split form design. I want to hide a field which I have already set a default value for. But when I make it invisible, the default value is not being recorded.
Combo boxes cboTN and cboSB are on my main form. cboTN is a search combo box that updates combo box cboSB with one of 3 values (ID, IDC, or MC).
I would like to do the following:
1: If the after-update value of cboSB is ID, subform sf1 will be visible. If the after-update value of cboSB is IDC, subform sf2 will be visible. If the after-update value of cboSB is MC, subform sf3 will be visible. (only one subform visible at a time since they are stacked in one place on my main form)
2: Once the appropriate subform is displayed, is it possible to use option buttons to set the property of the subform to either Add-only mode or Edit-only mode? If so, how? (perhaps some sort of Case A, Case B scenario with the option buttons?)
If you can help with either of the above; example codes would help my novice skills greatly!