Check box disabling - ms-access-2007

I am doing a project of managing a database. Here I have to make a checklist wherein a check box in an MS-Access 2007 form employees have to check in so that their responses get registered in the database. But, after a certain time, that is the deadline field, I want to disable the check box so that no more checking in is allowed. I am completely new to VBA. I would be very thankful if someone could help me out or guide me through the programming part of this.

In your VBA that will control this checkbox, there's a few options you can use.
MyCheckBox.Enabled = False
MyCheckBox.Locked = True
MyCheckBox.Visible = False
The first one will disable the control and grey it out.
The second one will lock out any changes, but it stays the same color.
The third one will completely hide it.
Hope this helps. Good luck.

Related

Can Access ensure a new form record displays all fields?

I have a database where I don't want some fields showing depending on data in other fields. I'm still new to VBA, having learnt how to do things I need via the internet (there's not much call for it in my job so like to try it out on side projects) for the things I need and have managed to create some code that hides certain fields that aren't needed, depending on what's been entered in another field and that works okay, if not perfectly (I'd like it to only work on the current record and not all of them at once but will worry about that later). My problem is, if I'm entering information onto a record and any of those fields become invisible exactly as I would want them to, then if I have more records to complete and load a new record, those hidden fields are also hidden on the blank record before any data has been entered and I want each new record to show all fields from the outset.
Another thing I've noticed is that if I close the database, next time I go into it the hidden fields have unhidden themselves again so I know I'm missing something important.
Here's a screenshot of a bit of the code where I want 2 other fields (What_reason and Date_sent_to_new_owning_School) to be visible depending on whether the answer in the current field after update is "Standard" or "Non-standard":
I'm sorry if this is really entry-level stuff but I AM entry level and trying to learn. This bit does work, albeit not perfectly as I'd like it to only work on the record I'm in at the time, and not go through and hide that field in all the other records at once (which it's doing).
I've searched everywhere but can't find the answer and although I've tried, I'm nowhere near good enough at VBA to try and use common sense to work it out. Is this something that can be done? I'm okay with computers generally and with Access too but I'm aware there's an awful lot I don't know and this is why I'm trying to do new things and learn stuff that I've not used before. I have tried all day to get this to work but am admitting defeat and am hoping somebody here will be able to help me. I'll probably need 'idiot level' advice if that's possible, I know my limitations. :)
Do you know how to use the Event tab in the Property Sheet? You can set all of your fields to [field].Visible = True on either: On Current, On Load, or On Open
Screenshot of the Property Sheet and for the field that determines the visibility of all of the other fields; you can use the Event: After Update so that way when you click/tab away from that field, it'll make those changes for you!
Property setting affects ALL instances of control. Control will be visible/not visible for all records depending on conditions of current record. Therefore, dynamically hiding controls on form set in Continuous or Datasheet will NOT give the desired result of
only work on the current record and not all of them at once
Db is not going to 'remember' dynamic setting - code needs to be executed when form opens and/or navigating records - so it is needed in OnCurrent event as well as control's AfterUpdate.
Conditional Formatting can dynamically enable/disable textbox/combobox by record although control is still visible.

Need help on excel autocomplete function for drop-down list

I'm trying to add an auto-complete function to some of the boxes on the first sheet that I have for entering data on an excel worksheet, but I can't figure out how so. Here's the link for the excel document. https://drive.google.com/file/d/0B2ksoDGxry1tR2JGNnhoSEZuYU0/view?usp=sharing
I have read some of the articles here but I didn't really get how to apply them to my work.
There is a very handy guide for doing just that, but you need to rely on a mixture of VBA and form controls, specifically comboboxes. The initial method was outlined in a slightly revamped guide by Contextures.
This guide was later expanded into, what I felt, was a slightly easier and more robust method dubbed "the magical floating activeX control".
I hope you have luck with those two - but knowledge of VBA will help you get the most out of it. You have to customize their setup to match your data structures. I use this method to produce 'autocomplete' forms for users in my organization. So far, my one extension has been to make an 'on/off' button for this code, because it's method runs constantly, meaning that you lose the ability to do UNDO in excel while the lookup/autocomplete code is available to the user. I strongly advise setting up a button/feature that allows a user to disable it when not in use.
For enable/disable, here is the very-rough code that will do the job to ensure the code doesn't execute when you don't want it to. This disables the 'catch' that watches for the intial value change in the script from the links above.
If Application.EnableEvents = False Then
Application.EnableEvents = True
btn_Enable.ForeColor = 0
Else
Application.EnableEvents = False
btn_Enable.ForeColor = 35653
End If

Excel VBA - Allow input to cells with DisplayFormulaBar=False

OK it's taken me a while to figure this out and it is extremely annoying...
Excel 2013 Pro Plus Fully patched to July 2014
In my project I have
Application.DisplayFormulaBar = False
which works as expected, it hides the FormulaBar. What is NOT expected is that it Stops the inputting of data into any cell.
I have to do a
Application.DisplayFormulaBar = True
to allow the inputting of data again which is inconsistent with the design of the application.
Does anyone know of anyway to hide the FormulaBar and still allow input into cells?
I'm using my own validation inside the VBA code to ensure right place and value...other cells are locked.
Many thanks in advance,
regards
Seán
I'm a Program Manager on the Excel team, and I wanted to provide some input on a bug we discovered that seems related to what we are seeing. Specifically, in Excel 2013 and later, when the formula bar is disabled, you (1) call DisplayAlerts = false (2) from an ActiveX control, you will get into a state where you can no longer edit cells. You didn't mention conditions #1 and #2, but it seemed related, and it might be the same issue you are seeing.
We are fixing this particular issue in an upcoming update to Office365. If you get into this state, one way to work around it by setting DisplayFormulaBar to true, then back to false.
Press Alt+T+O
Advanced
Editing Options
Give a Tick Mark in Allow Editing Directly in Cells
Source (scroll down)

How to Make Exception Handling on VBA Excel Form Combobox?

I have this userform that i'm developing for my report formatting task. My whole code is finished, there are only 2 problems that i need to work on.
Making my VBA application work on every excel file that user choose
Exception Handling for ComboBoxes on my form.
(Edit: I hope trying to get attention of people who are interested in this question to another stackoverflow.com topic is not against forum rules)
You guys can reach first problem's topic from here: (There is already one suggestion but i'm little bit confused. So it would be super for alternative suggestions) http://bit.ly/VnF3cK
And about my second problem, when i click empty place of combobox, i can type whatever i want, but i want to restrict it, so users can only choose values [1-5] that i put inside of combobox. How can I achieve this?
In answer to your secondary question, you need to change the ComboBox's Style property to frmStyleDropDownList

VBA Status Bar

I am working on a Word VBA macro app for 80 or so users. The office has high staff turnover, so training suffers, and so one of the self imposed requirements for this project is comprehensive, friendly documentation. However, to supplement this, and to save newbies having to open up a 100 page document when they want to try something new, I want a status bar on every userform (there are five) that provides contextual help. I find tooltips annoying.
I don't have a lot of experience, so I was wanting to
Essentially, I have a file containing every status string. (This is currently a text file, but I was wondering if I should use a spreadsheet or csv for ease of editing by other staff in future.) Every control has a MouseMove event which refers to a function: getStatus(cID) that opens the file, grabs the line and displays it in the status label. It also grabs a few parameters from the same line in the file, such as whether the label is clickable (to link to a page in the help file), and what colour the label should be.
So a few questions really:
Will the application be slow if a userform is constantly referring to a file? It feels fine to me, but I've been in it far too long, and I'm the only user accessing that file. There will be 80 constantly accessing it.
Is MouseMove over a control the best way? Should I instead use co-ordinates?
Most importantly (in terms of me having to do as little work as possible) is there some way to do this so that I do not have to have a MouseMove event on every single control? I have a good few hundred or so controls, each with their own identifier (well, not yet, but they will if this is the only way to do it). Maybe when the form loads I could load ALL the possible status lines so they're ready for whenever the control is moused over. But then, maybe the loading time is negligible?
Appreciate any ideas or thoughts - especially if VBA already has a whole range of functions to do this already and I'm just trying to reinvent the wheel. I can't use the application status bar, because the user rarely sees the application itself.
Thanks!
EDIT:
It is for both data entry, clicking around and a bit of document generation.
It is a controlled environment so macro security issues aren't a big concern for me - and if something goes wrong it's someone else's fault or problem :)
Is this data entry app or do they just click stuff? Because often the field with focus is different to the item the mouse is hovering over, this can cause a lot of confusion.
Constantly reading from a file is a huge waste of time and resources - it is much better to load them only once into an array or collection when the form is loaded.
On MouseMouse event is better than coordinates because you can move things around without worrying. It's a lot of code but you should be able to generate most of that if you have a list of control names because the code should be identical.
ie
Sub Control_MouseMove()
DisplayStatus(Control)
End sub
I would consider the StatusText property and ControlTipText property of controls for this kind of help.
StatusText
This example sets the status bar help text for the form field named "Age."
With ActiveDocument.FormFields("Age")
.OwnStatus = True
.StatusText = "Type your current age."
End With
ControlTipText
This can be assigned from the property sheet for the control.
Private Sub UserForm_Initialize()
MultiPage1.Page1.ControlTipText = "Here in page 1"
MultiPage1.Page2.ControlTipText = "Now in page 2"
CommandButton1.ControlTipText = "And now here's"
CommandButton2.ControlTipText = "a tip from"
CommandButton3.ControlTipText = "your controls!"
End Sub