Adding a "New Button" option on Access form - vba

Please forgive me if this question is too vague or extensive. I have limited experience with Access, SQL, and VBA and have a problem at work that I just can't solve. I'm trying to add a "new button" button to the user interface on our Access database.
I would like it to maybe bring up another form that allows you to input a query you want to make into a quick link on the home page. Obviously this would only be accessible to certain users but I can handle that part.
I don't necessarily need the code written, just an idea of where to start. So far all I've been able to do is hard code a new query or link into a button each team I want to make one. I want this process to be simplified so that anybody can make a button even if they don't know how to use Access very well.
Again, any help would be greatly appreciated and feel free to tell me to get lost if this is too vast or general a question.

I would like it to maybe bring up another form that allows you to input a query
The above seems very confusing. You are asking how a form can be used or launched or displayed to allow the user to add a new record. Then you toss in this VERY unrelated concept of some query? What does some query have to do with adding a new record?
If you want to add a new record, and you are in a form that is displaying current records, then behind the button, you can execute this line of code to jump to a new record ready for data entry:
DoCmd.GoToRecord , , acNewRec
So, that is one line of code.
If you want to launch an existing form and have it start out with a new clean fresh record, then use this:
DoCmd.OpenForm "frmCustomers", , , , acFormAdd
The above will launch the given from in "add mode" and thus you are again on a new fresh record ready for data entry.
The issue(s) of some query etc. for the user What does that have to do with wanting the user to add a new record? So that part does not seem to apply to the basic idea of presenting a form with a new record which allows the user to add that record in question.
You have to explain what all the hub bub about this magic query issue but to jump a form to a new record for the user? Just use the first line of code behind a button.
And if you need to launch a form in "add mode", then use the 2nd example one line of code behind the button in question. None of this has really anything to do with some "query" in regards to you wanting the user to add a new record. You can expand on what you mean by some user query, but you have several options to jump an existing form to a new record, or launch a form in "add mode" to allow adding of a record. In these cases, you don't need nor want to write or deal with some SQL query.

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.

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.

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.

Add new record button not working

I have an Add New Record button on a form. Whenever it's clicked I get an error "You cannot go to that record"
I have what I thought was the same setup on another database and it works just fine.
It's possible your query is 'read only' and potentially contains joins.
Are you using access? I made an assumption that you are. Please provide details as that will help you get a better answer.
http://allenbrowne.com/ser-61.html

Update ms access database via vb.net

How can I do that?
I already have the code I'm working on but it seems that it doesnt work really fine.
Here is how my program works. I input an id number(unique) on a text box and click the search button. The entries that corresponds to the id number is then displayed on the other text boxes.
And then I try to edit one of the entries manually(changing its letters or name) then I click the update button.
Here is now the problem: It really updates the entry but it makes a mirror of the entry with a different id number(maybe automatically generated).
So basically the ms access database will now contain the old entry and the updated version of the entry.
I can show you my code if you wish to. As long as I am assured by your reputation in this site.
Show the code, seems like you are using insert instead of update.
OK, check this link DataAdapter.Update Method
You seem to be missing
' Without the OleDbCommandBuilder this line would fail.
builder.GetUpdateCommand()
before
adapter.Update(dataSet)
Let me know if this works?