Access: Update and Append in same form - sql

I am new to using the front end tools/VBA in access, but I am an advanced programmer.
I have a situation where I need to record the date, and method of commute, for a particular individual on a monthly basis. What I have done so far is programatically create a form that lists every day of the month and has a blank space next to it for the user to enter in how he commuted. User only has to fill in if he/she clean commuted. The question is, how do I:
1. Select Records that have already been entered for a month and populate them to a line on my form.
2. Show a blank space for a user to enter info on any date that is not associated with a record.
3. Update any records they changed.
4. Append any new records they enter in the blanks.
I need to do this all on one form so it is easy. I cannot ask the users to navigate.
I appreciate any suggestion that might lead me to a solution. Many thanks.

A standard bound form will do that.
Use the wizard to get started and specify your table as the source.

After much testing and working (strange not find examples of this), I have determined the way to do this.
Do not programmatically create the form.
a. Forms in Access are tied so closely to accesses "form binding" functionality that there are to many limitations trying to work with a programmatically created form. It's very difficult to do.
A better solution is to programmatically create a temporary table that has the correct data structure and bind the form to that temp table.
a. thus the only programmatic part of your form is setting the bindings. Once that is done, you can rely on the form binding in Access to work easily with your Select, Update, and Append functions.

Related

Access Form switches unintentionally between Datasets

I am rather new to coding an Access Application and I have a rather strange error I do not seem to be able to resolve.
I have multiple Forms which are used to write data to some tables. Basically one Form per table.
Mostly the forms are just used to show a selection of the data in the tables. To make sure that noone accidentally alters some data you have to press the button "alter" first, which unlocks the fields to alter the dataset. In one form, however, when you ppress the alter button it switches the dataset. I have one column which is an automated ID which serves as a primary key to distinguish the data from one another.
So when I am debugging the issue and print this ID (Debug.Print Forms(formName).Controls("ID")) it returns the ID of the data that I want to alter, but as soon as I access the data and change one field (Forms(formName).Controls("Column1") = "foo") and print the ID again the ID switched to a completely different dataset.
I have absolutely no clue how that could happen. There is no other code being processed in between. I have googled for multiple hours but have not found anything in this regard yet. Maybe I am just using not the right keywords.
Any help is highly appreciated.
Thanks in advance :)

How to make records read-only once entered in query?

I have a form that a user will input data into, which will then send the added record to the backend of the database (I split the database so that the frontend is accessible to users while the backend is hidden). The frontend also includes a query with no filters, so that it will full portray the backend. This way, users can either input data via the form one record at a time, or add multiple records to the query (and therefore the backend) by copy/pasting from an excel sheet with a specified format (so that the data will be pasted in the same order as the fields of the query).
I want the user to not be able to edit the data/record once it is submitted, but I still want them to be able to view it in the query and/or paste multiple records in the "(New)" record row. Is there a way to make all entered records "read only" per se, but still have the ability to enter new data (i.e. make user unable to edit previous records, but be able to add new records)?
I used this forum as a reference, but the only solution I've come up with was to make the Recordset Type "Snapshot", which does all that I want, except it disables the ability to add a new record.
https://answers.microsoft.com/en-us/msoffice/forum/all/lock-the-entire-record-once-certain-textboxes-have/24f53c0a-2435-48b2-bf91-6713ff8b60ee
I've searched far and wide, but unfortunately haven't come up with anything. Any help would be greatly appreciated. Thank you!

Printing Form (on current record)

I have a form that computes a very extensive calculation based on inputs which are all saved in a table (declared by Control Source) by a unique identifier.
I export this data into Excel and reformat with a macro. I lose the formatting of the form.
I found that with the form active, I can print this form. The print includes multiple form copies for each record in the table and I do not see this being very user friendly.
I investigated online and see the typical workaround would be to print the unique record based on a report, though I would again lose the layout of the form.
My question would be, if I create a copy of the table I am storing my data in (as to capture all columns I am currently using on the original table) and maybe even the form I desire to print, could I have an on-click procedure that would save only the current record and all its inputs to the "PrintTable", and be able to print only the current record, then after it prints clear the table of any records?
Providing answer as unable to comment.
Can you not recreate the form as a report? Forms are not designed to be printed, however Reports are specifically designed for this purpose. And you can pass through criteria onto a report. And have virtually the same sort of design as you can put on a form.
Creating a duplicate table just to overcome the issue you are facing flies in the face of normalisation techniques, and should absolutely be avoided at all costs.

Structure of first database design

I’m trying to create a database where the operator (me in this case) receives a log and then assigns multiple people to review this log based on the various subsystems they represent. So for example, a test is run called x. Once x is run, I receive the log of x and assign five people representing different subsystems to review it. What I’m trying to do is manage all the reviews and see if any reviews are outstanding. The structure I was hoping for, and what I have implemented so far consists of the following: I have two forms in which to enter data, one for the run information that I enter, and one for the reviews that the other people enter. The problem I’m running into is how I’m able to view who has done each review. Below is a picture of the relationships I have of my database (the two letter acronyms represent the subsystems I’m assigning):
I originally was thinking about creating a query where I would be able to search by last name and show who had done what review based on whether or not they had checked the Done Review box on the review form. The problem with this was that unless a person created a review then a review wouldn’t exist at all so I wouldn’t be able to query whether or not they had completed it based on the check box. The other idea that I had was to add a check box for each sub system in the run information table and then map the check box in the review form to that check box in the run information table based on the RUN ID and Domain info they entered into the review form. I haven’t been successful in that either as I haven’t found a way to dynamically update the control source of the check box in the review form. Anybody have any ideas of how’d they’d implement this or something I’m missing? This is my first dealing with database development and I’m at a loss right now. Thanks.
The tables have one-many relationship , you can use Ms-Access to build your tables, queries and master /detail form by wizard.
You can modify it by vba code.
At least you get starting system.
Edit:
Master form: RunInformation
Detail Form: Review
Link join field between master/detail: RunId
in this case , for any RunInformation in master form , you can insert the five records assignment for each sub system
You can do all CRUD operation for master/detail
q: "What I’m trying to do is manage all the reviews and see if any reviews are outstanding."
A: add a button in the master form that filter master/detail form where status is "oustanding".
Note:
Modify structure of "RunInformation" and remove columns of the subsystem (like hw,sw,..),and add status column in the "review" Table and column for the subsystem (hw,sw).
You can do it as combo box in Review form, and status as checkbox.

Display multiple query results in a list box?

My Access form has a list box that displays files the user has selected from an OpenFile dialog box. What I do is copy these list box files into a seperate folder on the network and I save this network path in a tblAttachments table. This table has a one-to-many relationship with my main table - tblIdeaDetails.
I created a query that selects records from the tblAttachments table:
SELECT tblAttachments.attachmentPath, tblAttachments.attachmentIdeaID
FROM tblAttachments
WHERE (((tblAttachments.attachmentIdeaID)=[Forms]![frmIdeaSubmission]![ideaID]));
My question is, how can I display the results of this query in that same list box when the user is navigating through the records (frmIdeaSubmission in this case, which is bound to the tblIdeaDetails table)? I've tried doing a requery, but I kept getting an "Out of stack" error.
There isn't a lot of information to go on with your question but let me see if I can help anyhow.
My suggestion is to isolate your problem and work it out before incorporating it into your project. Create a new access database and make a 'demo' of what you are trying to accomplish.
The reason I'm suggesting this is because an 'Out of Stack' error is memory related - could be related to database corruption - a whole myriad of reasons.
Microsoft Support lists a few reasons:
http://msdn.microsoft.com/en-us/library/aa264523(v=vs.60).aspx
As identified by the support page, it can be dependent upon a number of factors that are going to be present throughout the database.
All things being equal, if you have your listbox recordsource bound to the query you indicated - calling the requery method on the listbox object should do the trick. Changing the record should also force a requery if its bound to a data source.