MS Access - searching for better method to create and edit records - ms-access

I have made a database that I use at work for tracking tags that get signed out. The way I currently have it is I created a table that has 100 records manually entered already. Field Name "TagNumber" 1 to 100. There are several other fields for every record that is currently blank.
A user will have access to a form that they will select a tag number from the "TagNumber" dropdown list. Doing this will allow them to fill in the other fields with the correct info for that tag. When finished they will click a save and exit button that will modify that record they just put the info in for. It will also update a Field named "SignedOut" it is a data type Yes/No field. Once the user has signed out that tag number it will no longer show up on the dropdown list when someone else goes to sign out a tag.
On the same form there is a "SignIn" dropdown list that only shows the tags that are checked yes in the "SignedOut" Field. When a user selects a tag to be signed they enter their name and date and click save and exit. Clicking the save and exit button will run a macro that copies all the data on that single record to another table for tracking purposes. It also sets all the fields back to blank except the "TagNumber" field. This allows another user to sign out that tag again.
examples of my tables:
Nothing signed out yet
Tag 4 signed out
Now my issue I am running into is If I provide this to another section they have different tag numbers and I don't want to have to go to the table and physically change every tag number. Is there a way I can auto populate the list with different tag numbers? or is there a way I should be doing this that is completely different from the way I am doing it?
Thanks for any info you can provide.

Related

How do I get my Access form to re-open to the last unbound text box entries?

I have created a form to update criteria in various queries in my database. I have 4 unbound text boxes. The user enters the new dates into the text boxes and I've added a button to run the queries. The query results look great.
The problem is, I want to be able to close the form and upon re-open have the dates that were last entered re-appear. Instead, the text boxes are blank and the user has to re-enter the dates.
Basically, the same dates will be used for a month, then at month end, the dates will change. I would like to be able to set the default to the last entry.
Is this possible?
Rather than using unbound textboxes, consider creating a table containing a single record to store the values entered in each textbox, and then use the table fields as the Control Source for each textbox.
This way, when the user enters/changes the value in the textbox, the underlying table record is automatically modified and will be automatically reloaded when the form is reopened.
You can also set the Allow Additions & Allow Deletions properties both to No in the Form Data properties, so that the user cannot create/delete the record in the underlying table being used to save the textbox values. Make sure that Allow Edits is set to Yes to ensure that the user can change the values in the textboxes, and that the Recordset Type is Dynaset so that it can be edited.
Using this method should also not require any changes to the rest of your existing application, since the values held by the bound textboxes may be read in the same way as if they were unbound.
It's hard to know exactly what you're asking without seeing the code you have, but if you are using VBA, you could look into the difference between hiding the form and closing/unloading the form as described in this answer. If you hide the form, it won't be visible to the user, but it will still be loaded, so your text boxes should keep their values. When the user needs to interact with the form again, you can un-hide it.

Updateable subform adds "#http://#" to end of hyperlink field when edited

I have a form with a subform that lists current material information being entered on the main form, like a log/history view.
On the subform there is a field that specifies which skid the product was assigned. I made this field a hyperlink so that I could use the OnClick event to launch a report and be able to extract row information needed to generate the proper summary.
That works great, and I thought it was finished until I attempted to edit the skid number from within the subform.
Allowing edits in the subform is a project requirement. Editing the skid number in the hyperlinked field breaks my code. Access automatically appends #http://# to the end of whatever value I enter into the cell and updates the table with this string. That row then gets omitted from the report because I'm keying off of the skid numbers. By design, this hyperlink has no path or address, I just use it to determine which row is being clicked.
How can I prevent Access from appending the #http://# while keeping the "Is Hyperlink" property to Yes? Is there another property to set this behavior or should I use the AfterUpdate event to undo the addition, which just seems like a waste of resources?
I am running Access 2010.
There is a long and very thorough article here that I will not copy ;) It elaborately states why its a bad idea to even use the hyperlink-field and what to do to get the same result you need without a hyperlink-field.
Basically, the main point of the hyperlink-field is all that behind the scenes shenanigans you cannot do anything about - and thats not what you want as a programmer.
The Hyperlink-field internally consists of three parts: A Text-part, a Link-Part and a Tooltip-Part. And although you can access them separately, access always tries to create a link.
You can try to format the data you have in the internally used format (DisplayText#Address#SubAddress) but I think that is not what you need...
So I think you best take Philipps advice and change your field-type.

MS Access - Form tries to create new record on open and record jumps about a continuous form

So I have two issues with my database, which I think are linked together.
Firstly if tblDeliveries is empty and frmMainView is opened it comes up with "You must enter a value in the 'tblDeliveries.deliverySlot' field" but the form shouldn't be trying to create a record and I can't see any reason why it would. Opening frmDailyView (which is a subform of frmMainView) doesn't show this behaviour but it is the one with the continuous form on...
Secondly if tblDeliveries has one (or more) rows the first row of the table will jump about... For example in frmMainView if the date of the first record is set to 23/01/2015 and you navigate to the 24/01/2015 and click anywhere on the subform and then press F5 to refresh the record will have jumped to that date, the date even changes in tblDeliveries.
I have no idea why it's doing it, I even removed all of the VBA code for the form to stop it, but it happens anyway.
If anyone has come across anything like this before, please let me know how you fixed it, or any suggestions would be very welcome. Thanks!
EDIT: If you download the database, add your computer login name to tblUsers. Also the date is UK formatted, so might need tweaking to work with US dates.
The offending database (1.5MB)
Taking a look at your database, several issues are occurring.
You first issue can be resolved by going into the Design View of the table tblDeliveries, select the deliverySlot field and change Required (in bottom panel) from Yes to No.
Your second issue is multi-faceted with many issues but a critical problem is that the parent-child link field, deliveryDate, between the main form and subform is missing in the recordsource of the sub form and the field's table origin is not in the query's join statements. For me, I can't even update anything in subform (all boxes are grayed out).
Essentially, you are trying to normalize Delivery Dates and Delivery Times (one-to-many) but the left join query (qryDeliveryIncBlanks) setup is not aligned to this effect. You user login also does not integrate smoothly into frmMainView. My ultimate advice is revamp your database design relational model then use forms as the visual representation of those related tables.
I am not re-iterating the points of #Parfait.
Access Forms have a property DataEntry. If it is set to Yes (or True in VBA), then the form will open itself pointing to a new empty data record. Set this property to No (False in VBA).
If you want to give the user the possibility to manually enter a new record, set the property AllowAdditions to Yes and to No otherwise. Yes displays an empty record marked with a star * and the end of the data sheet or continuous form.
I've resolved the issue, thanks to some of the comments I realised I could just give the deliverySlot field a default value with a number outside of the range it would look for, I set it to 99, but it only looks for 1-20. The date still jumps around but since it's not in the range of the query it's hidden. It's resolved both issues.

Form Customization without VBA

We are rebuilding an asset database with Access 2013. We have 1 table with a Primary Key (Serial number of asset), and 22 other fields. We're designing a form to be used with the table so that we are not manually editing the table. The 'Status:' field explained later does not exist in the table; it is a user friendly way to show if the record exists or not.
The end goal is to have a form that will two cases. A user will enter a PK and hit the tab key. Then:
If the PK exists, it will pull the info from the other 22 fields and put them into the fields on the form (1:1) and update 'Status:' to 'Existing'.
If the PK does not exist, it will change the 'Status:' to 'New' and make all of the fields blank.
Most of the fields on the form will be Combo boxes. There will be a couple text fields and 1 date/time field.
Once a user is done with the form and has made any necessary changes, there will be a 'Save' button at the bottom that will write whatever is in the forms to the row indicated by the PK.
I have found partial solutions with the LostFocus() event in Access 2013 on the PK field of the form. I have little experience with MS Access, moderate experience with DBA, and no experience with VBA programming. I'm sure this solution can be done, my question is: can it be solved in a way other than hard coding the solutions? I also looked around for form building, but I couldn't find anything that worked how we need it so if there is a tool that can accomplish this, that is acceptable.
You might consider a form that contains a subform. Basically, you would design a form that has your PK input box and a subform. When the user hits tab (or a "Search" button), a query would run to search the table and display that record in the subform, or you could insert a new record if not. You may need to use a few queries and macros to link it all together, but it can be done code-free.

How to look up values from a table in Access

I have an Access database that is used to store basic info in a table such as first and last name. How would I go about adding the functionality to lookup by last name?
Is there a way to type in the last name and then hit like F12 or something like this? Can someone please point me in the right direction or provide me a link?
SELECT tblPatient.LName AS [Last], tblPatient.FName AS [First]
FROM tblPatient
WHERE (((tblPatient.LName)=[Enter Last Name]));
How do I tie this into my form now?
I'd suggest you create a form, with a textbox 'search' at the top, then either a listbox or subform below to display results.
The listbox record source would be:
SELECT tblPatient.LName, tblPatient.FName
FROM tblPatient
WHERE tblPatient.LName LIKE Forms!myForm!search & '*';
You can either add a Search button, which requeries the listbox, or do the requery via the Change event of the search textbox. The later may be slow if you have a large number of records; if that's the case, you could check that at least 3 (?) characters have been entered before calling the requery.
You just need to create a query in which you put =[?] as the "last name" value.
When you open that view, you'll be asked to type in a lookup value for that field.
Not sure if this is what you are trying to archieve, though...
This is probably a bit overkill for what you want to do, but I assume that you want to perform a search by last name. You should be able to glean the information you need from this article:
Build a search criteria form
http://www.everythingaccess.com/tutorials.asp?ID=Build-a-search-criteria-form
You can create queries in Access if the user you're targeting with the searchability has Access themselves.
From the main Access UI (assuming Access 2007), go to the Create tab and then select the "Query Wizard." Here is an article on the subject.
Otherwise you can create a program and connect to the MDB/ACCDB file running the query programmatically.
Seeing you wish to look up a name and populate the form based on the name selected, I suggest you need a combobox. There is even a wizard for doing exactly what you want. To start, you will need a form bound to a table or query, that is a form with a Record Source.
Add a combobox to your form
Select :
Find a record on my form based on the value I select in my combobox
Select the ID (primary key), Last and First name fields.
Access will display an example, suggesting that you hide the Key (id) column. Accept this.
Choose a name and finish.
There are a few other small things that could be done for neatness, but you will end up with a form that find the record you want. In addition, the combo will autocomplete if you type in a few letter.
If this is an mde, which your subsequent post seems to suggest it is, there is little you can do wuth out the original file. However, you could try opening the database while keeping the shift key held down and see if that allows you to edit. If you cannot get the original and the shift does not work, you could try rescuing the data, if it, too, is stored in this file.