Clear auto number field on a Form using clear button - vba

I'm new to MS ACCESS, I would like to know if there is a way to clear an auto number field using a clear button. I've tried to follow some videos on you particularly this one but it seems to be not the proper way on how to deal or create an auto number field.
This is the image is the sample of the form which I'm experimenting with this particular subject.
And this image is the error code which I'm getting right after I clicked the clear button.
[![enter image description here][3]][3]
Below is the code I use for this experiment.

You don't need to clear autonumber field, it handled automatically. So, remove EnployeeID field from INSERT statement and delete rows with Me.txtEmployeeID from clear procedure

The AutoNumber Data Type is assigned automatically and can't be
changed. Also once you enter data into some other field like Employee
Name(New Record event initiated), access will assign a value to the
AutoNumber let's say 1. If you press Esc, access will cancel the edit. Next time you create a new record access will assign the value 2 and so forth. Unless you repair the database then access will reset the AutoNumber counter.
If you want a data type that you change its value, you need to change the Data Type to Number. In this case you need to assign each value by code or by the user input.

Related

MS Access - Continuous form custom text entry

Good Morning All,
I am wrestling with a problem with continuous forms.
I have a continuous form based on a query that pulls transaction information from a table.
I want to have text box on each row where the user can override the fee value, at which point when the submit button is clicked the overridden information is written into a second table in the database.
When I add an unbound text box onto the continuous form I end up with all entries reflecting the amount I have just entered.
If I add a dummy column onto the SQL query, I am unable to edit the information.
Is there a way to do this? Below is an example of the form input I am shooting for:
Snip:
I don't think this can be done in Access.
I think the closest you can get, is to display the value from the secondary table in your continuous form; and then, after some user input (focus into the textbox, or double-click the text box, or button click), prompt the user to enter a value using either the VBA InputBox function, or leveraging the built-in Zoom box. Check that the user-entered value is a valid number, update your external table, and refresh the query results.
You might also create a custom form to validate the input.

How can I jump a form to a specific record in Access?

I have an Access Form which pulls records from a table. The user will interact with the records, sometimes in chronological order, and sometimes by jumping direct to a specific record.
The table uses a field called ID as the primary key which auto-numbers when a record is created. This is what the team will use to jump directly to a record.
I need to create a textbox where the ID number can be inputted and then a button to carry out some code to jump to the specified record if it exists.
I have attempted to put bits of code together what I have found online but so far have had no such luck in making anything work.
I would be very grateful if anybody could advise me and provide a code sample to make this work! :)
Make use of the RecordSetClone and Bookmark properties.
Use the RecordSetClone property to obtain a copy of the form's recordset that you can manipulate without affecting the "live" recordset used by the form.
Locate the appropriate record in the cloned recordset (perhaps using the FindFirst method), and obtain the Bookmark which uniquely identifies such record in the recordset.
Set the Bookmark property of the form to the Bookmark value obtained from the cloned recordset in order to change the current record displayed by the form to the record found.

MS Access - setup combobox to allow input of data not in the tables

I need help with MS Access 2010.
One of the client's requirement is they need to be able to input new data and also be able to have a drop down list of the data existing in the table for selecting using a combobox. Im very new to MS Access, only managed to work around it using online tutorials. Im not too clued up with VBA coding. I have tried swicthng around the properties components, still not working.
please assist.
thanks
That's what I have done. Wanted to allow free entry but still assist the user if value already exists.
One option is to use the data table as source for the combobox RowSource. Set the combobox LimitToList property to No. Then the combobox RowSource would be like:
SELECT DISTINCT fieldname FROM tablename WHERE NOT fieldname IS NULL ORDER BY fieldname;
However, if you want a new value to be available for next record for a continuous or datasheet form, the record must be committed to table and then requery the combobox. Record is committed when: 1. close table/query/form; or 2. move to another record; or 3. run code to save. So code in the form Current event like:
Me.comboboxname.Requery
Another option is to have lookup table for the combobox RowSource and set the comobobox LimitToList property to Yes. Then code in the combobox NotInList event to allow new value input by user to be saved to lookup table. Review: https://msdn.microsoft.com/en-us/library/office/ff845736.aspx
Apologies for not being clear... i have however managed to fix this by pointing the row source to a table. This has allowed me to be able to do a selection on existing entries on the table and also "allow" adding new data using the same combobox.
thanks.

RSA Archer - Calculated field based on Record Permissions field

I would like to have a complete copy of a Record Permission field.
For example - I have a field "OWNER" which is Record Permission type.
I want to create another field called "OWNER_COPY" which will always include the value which was selected in the OWNER field.
I thought of few ways to do so but none succeeded:
Crete a new Record Permission field (OWNER_COPY) but it has no option to be calculated (it doesn't have the option: "Set the value of this field using....")
Create calculated Text field (OWNER_COPY)- but if I'm writing [OWNER] in the formula it will provide the ID of the value and not its name.(e.g. if the owner was "Oliver", I will get his id - "123"" in the "OWNER_COPY" field).
Crete regular Text field (OWNER_COPY) and add a rule. but I couldn't find any kind of rule which can fit this case.
Any suggestions?? Thanks in advance :)
Archer can't copy value of RP to anther RP.
I used a custom object for this purpose. The limitation is that the field will be populated only when end user actually interact with a form. The good thing is that the field will be populated instantly.
As an alternative you can use a data feed as Tanveer described above, but in this case there will be a delay between the time when you save the record and population of the 2nd RP field.

InfoPath 2010 NaN

I have been trying to update a text field in a form that will automatically generate a new number in a read only state when a user fills out the form. When the user completes the form and selects the submit button, the form will be attached to SharePoint List and the following user will open the form and the number field will be the number +1. I have used 'count(mynumber)' and the field returns 1, but when I close the form and re-open it, the field still displays 1 and never increases. When I use 'count(mynumber) + 1' the field returns 2 and also never updates. Finally, I used 'max(mynumber) +1' and it returns NaN. I have come to the conclusion that there is an array here, but don't know what I need to do, to fix this.
I have informed my manager of 'InfoPath 2010 Cookbook' so hopefully this will help, but I also took a gander as this following link, which was not easy to follow as I believe its for 2007 instead of 2010.
http://claytoncobb.wordpress.com/2009/06/15/auto-numbering-infopath-forms/
I am using SP 2010.
So, here is the simple approach to the simple request:
•Just like in any database, every item in every list and library in SharePoint has a unique ID. This ID is stored in the ID field, which is available for viewing in any list or library. Go to your list, modify the view, and check the box next to the ID field so you can see what I mean. This ID is 100% guaranteed to be unique and is never duplicated.
•Since you already have purchase order numbers, you can't use the IDs by themselves, however, you can use them to drive your auto-generated Service Order numbers
•The easy method for doing this is to utilize your SO field, which is now a Number field, and determine the differential between the next ID in the list and the next Service Order number that needs to be created.
•Then, create a simple workflow in SharePoint Designer 2010 that ONLY runs on the creation of a new item (only runs once per item/form), and set it to add the differential to the current item's ID (Something like Do Calculation: ID + 1200) . Next, use Set Field in Current Item to set your SO field to the variable created by the Do Calculation step
From then on, you will always have a GUARANTEED unique, auto-incremented SO # for each form, and you should make this field read-only inside the form so that users can only view it and not edit it.
--Clayton Cobb