Can Access ensure a new form record displays all fields? - vba

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.

Related

why does selecting "refresh fields on keyword change" load a whole new document?

Notes 9.01
Why does a new document on the web change unique IDs every time you refresh it?!? this causes all kinds of issues. Obviously it is a different document, so maybe I should re-phrase that, but I think you know what I am saying.
I have a listbox field, with the setting to "refresh fields on keyword change" selected. This allows hide-whens to recalc, and other fields to recalc. I also have a computed text showing the current #DocumentUniqueID.
choices are: "Select one":"one":"two":"three"
When using this form on the web, in a new document, and I pick something in this field from the drop-down, it refreshes the form, and the choice I just picked is removed and "Select one" is what is showing again.
Once the document is saved, this stabilizes and you do not switch documents, and field values do not get cleared. I just want to understand the logic of this and find out how other people work around this.
Any feedback would be great. If I am doing something stupid, please tell me, I can take it.
Matt
I don't know what the "all kinds of issues" that you're dealing with are, but for as far back as I can remember, Notes documents have not had a stable #DocumentUniqueID value (or any at all, actually) prior to being saved for the first time. It's been my practice, and I think pretty widely accepted practice, not to write code that would have issues with that. If it's been necessary to depend on some unique value in the document prior to the first save, I've always used a computed-when-composed field with #Unique for its value.
My suggestion would be to not use "refresh fields on keyword change" for a form used on the web. The way I would handle it is to use some JavaScript to handle that.
Personally I would do this, in your situation:
Add jQuery to the form, you can easily put a CDN link in the page
header.
Write a JavaScript function called (for example)brecalculateFields(). This function would calculate field valuesband perform hide/show of fields/sections of the form.
Set a class for all fields where you want to trigger a recalc of the fields when the value is changed. I would call the class recalcForm.
Bind the function recalculateFields() to the changed event of all fields with the class recalcForm.
You may want to bind the function to a few other events as well, depending on what type of fields you have on the form.
$(".recalcForm").on("change", function(e) {
recalculateFields();
});
$(".recalcForm").on("blur", function(e) {
recalculateFields();
});
I have blogged about this in the past, hopefully you can use some of the info there:
http://blog.texasswede.com/using-jquery-to-emulate-notes-hide-when/
http://blog.texasswede.com/jquery-a-flexible-way-to-showhide-sections/

How to have an auto filled field save into table?

i've had a look around for an answer to this but couldn't find a definitive answer (if some can point me at a thread that does answer this i'd appreciate it).
I've created basic database where queries are logged and then reported on. When someone logs a new query it goes into a table called "TBL Main Log", this is done on a basic data entry form and when they select "Country" a field called "Owner" is auto populated. However, when i click save at the bottom, this data doesn't get pulled through into "TBL Main Log". My save is run off a basic close window and save macro.
I have set up my autofill being fed off a combo box for "Country". I'm assuming i need to do something in the event properties after update. I'm pretty limited with my coding abilities so could answers be dumbed down as much as possible for me.
Cheers
Luke
Based on the comments:
me.Refresh on forms forces bound controls to save to the table.

How to know if a user has stopped their selection in a datagridview?

My scenario: I have a datagridview and it contains some data. User can select a row, or multiple rows in that datagridview, and they need to know a summary about those rows they selected.
Handling multiple rows in datagridview is easy enough, and I have no problem getting what the user need: Two numbers indicate how many item is selected, and their total weight in those rows. I passed that data to a small summary form to display, and I put the code to show that form under dgv.SelectionChange().
But then disaster follow: each time user select a row, that form will appear. Which is, if user select 20 rows, they will see 20 summary forms.... and any more than that, well.. you can imagine. I thought about putting something inside SelectionChange() to check if user has stopped their selection.. but can't think of any.
This seems like a very simple matter, but somehow I can't figure it out..
My question, how to know if a user has stopped their selection in a datagridview ?
I still don't have enough points to just comment, so my answer would be I don't think you can reliably without adding another control (ie, button). You can't read the users mind and since the number of rows can be variable, how would you ever know? You could try something like if the cursor leaves the DGV but that would be frought with issues as well. While it would be an extra click for those just selecting 1 row, I still think having a "Get Summary" button would be the way to go. Sort of like when selecting items to compare - you can click any number of items and while they may show which items you've picked so far in another area, the comparison table doesn't appear until you click the Compare button.
From what I understand, you actually have two options.
Add a button
Since you can't figure out when the selection is done, just add a button that will call the Form you want to display, that way you are sure that it will display only when user asks for it.
Use a timer
Another option is to use a Timer, every time the selection changed, you reset the timer to one second (to keep the example simple).
And whenever the timer does a tick, you call the Form and stop the timer. That way it will trigger one second (or less) after the user made the selection and gives him one second to change it...
Honnestly, I think the button option is the best, as you give the power to your user. Maybe they will want to select some rows but don't want to see your form, as they will only copy it to paste it somewhere else...

Access Field Not Refreshing

To start, I am using Access 2003 and have a similar project that works correctly that I designed.
I am stumped as to why a particular field will not change dynamically like every other field until I "refresh".
Currently I have a task list that lists all items that need to be works. Containing a Status: New, Open, Closed; The account number, person who is working it and more.
The tasklist is just a form with a subform with a datasheet view that opens the task when you double click it. If a user opens a task, that task will be locked until they move on. If any information that is viewed in the task list is changed, it dynamically updates, all but the Status (which really is the most important) until the user manually refreshes it.
Does anyone know what I need to look for that would cause this? The Status is stored as an integer that joins with it's true value. I thought this may be the reason, however I have a similar tool I designed does not have this issue.
I've look into how they are joined, the code that changes this value, everything seems the same between the working and not working.
Any advice?
Thanks in advance.
edit any fields that are JOINED, do not seem to dynamically update until I hit refresh. However, the other database has this working. What am I missing that is different between them.
Solved.
I changed the object displaying the field from a textbox to a combobox, showed two columns with widths 0";1" and it works.

focus on current record selected

i am working on a dynamic database which must be extremely professional and user friendly for the "non-access" users..
I am not sure if any code exists for this or if it is capable but I need to put a focus or highlight the record in a form (in a table type view) to emphasise with great details that the user is currently on that record. the little Arrow on the record selector is not enough.
My first choice is that the record currently beign used remains in black colour or perhaps even enlarges whicle the other records in the rows (above and below) are greyed or faded so that it is blatently obvious that they are not selected but are available.
I would greatly appreicate any advice..
Thanks
I googled 'access forms change current row indicator' and the first result was http://access.mvps.org/access/forms/frm0047.htm which looks pretty good (although maybe not very supportable).
The problem with what you want to do is that Access doesn't do that easily; Access does a lot of things for you at the price of accepting the way it does them. When you want to change that you will have problems.
Cheers -