Modules & VBA :: Renumber Records When One Number Changed?

Jul 11, 2014

I have a table which has 2 fields 1) Project_Priority_Number and 2) Previous_Priority_Number. If there were 100 records these would be numbered 1-100 in the order that the user originally sets the priority (this number is in addition to the record ID number). I have created a form with code that moves the Project_Priority_Number to the Previous_Priority_Number and then shows the Project_Priority_Number as blank and displays all of the records.

The user can then set new priority numbers in the blank column. Say they choose to make the old priority number 4 the new number 3 and priority 27 now becomes say 2, etc. I want the user to press a button that re-numbers the remaining ones based on their old position + or - 1 (basically to fill the gaps but based on their previous positions). I understand how to renumber if one is deleted but I don't know how to be more specific and re-number based both on their previous priority number and whether something else is now set to replace that.

For Example (the following numbers need to re-order based on previous priority 4 becomming the new priority 1 and the previous number 8 becomming 3 - so the previous 1 becomes 2 and then everything after the new 3 moves forward 1):

PROJECT PRIORITY NUMBER PREVIOUS PRIORITY NUMBER
1
2
3
1 4
5
6
7
3 8
9
10

View Replies


ADVERTISEMENT

Why Is The Number 00712 Changed To 712

Apr 24, 2006

Hi,

I have an complex code. In this code I sent the form value 00712 with query string and an insert SQL command to an Access database. The probleme is that the number is stored as 712 in the database. I do not want that.

Does anybody know how I can avoid this?

Thx a lot.

Flip

View 2 Replies View Related

Default Number Value Changed To 0 After Starting Enter Data Into A Form

Mar 4, 2015

I have a form that has number entries. I changed the Default Value for these numbers to Null because I dont want 0s (they aren't being used for numeric calculations, they just hold a number). I want there to be nothing in the input field until I put it there.

My problem is, when I start to enter info into my form, access automatically places 0s into all my number entries! Is there a way to avoid this? Or should I just make the fields text instead?

View 3 Replies View Related

Timestamping Changed Records

Aug 24, 2006

Hi,
I'm trying to populate a read-only field on a form with the time and date the record was last changed.
This is to acheive seeing a list of records that have been updated this week for example.
I have this at the moment:-

Private Sub Form_AfterUpdate()
Last_Updated.Value = Now()
End Sub

When I've updated a record it won't save and when I try to move onto the next record it does nothing, the button clicks but no response.
Does anybody have any idea where I'm going wrong or have any suggestions?

Would appreciate any help.
Thanks,
Dan

View 3 Replies View Related

Renumber ID Numbers

Jul 7, 2005

I have 8 databases (A97) (don't even ask me why) they are identical.
I want to combine all the tables from them into one big table.
There are two tables 1 called Transactions and it has a transactionID (number) (parent of DetailID) and the other table is called Detail and it has a DetailID (number) (Child of TransactionID).
The problem is in all 8 databases the transactionID is an autonumber starting at 1 so I will have duplicate TransactionID & DetailID numbers. Each of the databases comes from one of eigh different "Regions" of our company and we assign Region numbers I can use as a prefix to the transID/detailID.
I tried to put a "25" (region#) in front of the one of the TransID# by using the format property in the table design and that seems to act as some sort of gost because while you can see it in datasheet view when you click on the cell the "25" disapears and all you can see is transID#1...#2....and it also gets dropped on paste append to the new combined table.
The question: is there an easy way to put a region number prefix on transID# so I can merge all 8 transaction tables together into one combined table?

Thank you

View 3 Replies View Related

How To Renumber An Autonumber Field...

Oct 3, 2005

Hi

I want to renumber an autonumber field to remove the gap appear after deleting the record.

I know it is possible by deleting field and creating a new autonumber field having same name.

But all this I want to do with code.

I will be gratefull if any one help me.

Regards

:confused: Rahulgty

View 7 Replies View Related

Tables :: Appending Changed Records To Archive Table?

Aug 21, 2014

I have a single table database for inventory. Every 3 months or so, some records get changed or updated. My manager wants to keep an archive of all of the records that have been changed so we can go back and look at an history of all of the records. So, My thought is to create an "Archive" table, appended all of the current records to it. Then, when changes are made, create an Append Query, or what ever works, to copy just the changed records from the Main to the Archive table. There are only 200 items in the inventory so it is not a large database.

View 1 Replies View Related

Queries :: Append Distinct Records Only If Field Have Changed

Jun 5, 2013

Using a database 2010. I have a monthly import from a spreadsheet to one of my tables. Sometimes it has the same previous data from prior month or months that has not changed. I don't want to keep appending this data to my table if none of the fields have changed.

Is there a way to append data to table only if fields have changed in an append query? Ex. (Name, Address, PhoneNum, Rate) If all fields are the same; don't append. If one or more fields are changed; append.

View 14 Replies View Related

Forms :: Why To Undo Edits After Changed Records In A Form

Jul 22, 2013

I thought "Undo" was only available while in the current record.Here were my steps:

1 - Loaded form that shows 1 record per form page.
2 - Edited a record
3 - Moved to another record with status bar nav arrow
4 - Verified my edit was in the underlying table
5 - Moved back to the original record, again using status bar nav arrow
6 - Clicked my "undo" control and the original data appeared in the form
7 - Moved to another record
8 - Verified my original data was now back in the underlying table

My undo control has this vba on click:

Code:
DoCmd.RunCommand acCmdUndo

View 1 Replies View Related

Modules & VBA :: Date Format Changed On Its Own?

Jul 3, 2013

I have come across a weird event from the 1st July.

I have a form that inputs dates into the table.......nothing special.......

Form is totally unbound and the insertion to the table is done via DoCmd.RunSQL Insert every thing has been fine until the 1st of July at this point it started saving the date into the table in American format 07/02/2013 instead of UK 02/07/2013 There have been no changes to the database at all to give me a reason why this has happened.

The Table fields are set to Date Fields.

The SQL Insert was set to Date ( #" & DATE & "# )

The date displayed on the form is in the correct format to get around this I have set the insert of the date as a string ( '" & DATE & "' ) AND how can i reformat the dates that are incorrectly inserted to the correct format as they include the date and time 07/02/2012 11:11:47

There is about 1000 lines so manual change will be a nightmare.

View 8 Replies View Related

Modules & VBA :: Fill In A Large Number Of Records

Jul 23, 2014

I need to fill in 200000 records counting from 100000,100001,100002.... and so forth, just one column (and maybe the auto numbering).

make a new DB with these columns: ID, counter
set counter to 100000 where ID=1 (in the first record)
move to next record (or make a new record)
if ID < 300000 then set counter = 1+ (the value of counter in the previous record)
continue until ID=300000

View 8 Replies View Related

Modules & VBA :: Returning Correct Number Of Records

May 3, 2014

I am having trouble with the below returning the correct number of records, and can't see why.

I have one table, tblDevice, which has 4 columns, ID | DeviceRecNo | ExcludeFromCheck | StockLocationID

ID - Autonumber
DeviceRecNo - Number
ExcludeFromCheck - Number (1 = yes, 0 - No)
StockLocationID - Number

I have the following running as part of some code, but it is not returning the correct number of records, and I cant see why not. I have tried creating this in a query in Access itself, and copy the SQL into VBA and it still doesn't return the correct number records.

I have 4 records in there for testing, all with StockLocationID = 3, all with different DeviceRecNo, and two each of ExcludeFromCheck, 2x0 and 2x1

Code:
Public Function test()
Dim db As dao.Database
Dim rs1 As dao.Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("SELECT DeviceRecNo FROM tblDevice WHERE StockLocationID = 3 AND ExcludeFromCheck = 'No'")
Debug.Print rs1.RecordCount
End Function

View 3 Replies View Related

Modules & VBA :: Pull X Number Of Records From A Database

Jan 23, 2015

I need to first generate a random number between 1-4.

Then I would like to use that number to pull that many records out of the database; the records pulled can be random, or whatever.

For example, we have 4 people and my goal is to choose a random # of records to pull for each person. So, for person #1, it might only pull 1 record, then for person #3, it may pull 2 records, etc.

Ideally, it wouldn't pull the same # twice when run for that "session".

After this, I'm hoping to generate all those results into emails (eg for person 3 it would generate 3 emails, etc)

Currently it's all done manually and I think it's doable with Access.

I have some code already for generating "1" email message, but do not know how to pull X number of emails all at once. (X is the random #).

View 2 Replies View Related

Modules & VBA :: Calculating Number Of Days Between Records

Sep 10, 2013

I am trying to calculate the number of days between incidents.

If I have an incident that happened on the 10th August and another on the 15th August then this would be 5 days, the next incident occurred on the 28th August so that would be 13 days. The problem I am having is how to get access to use the latest date rather than the first date.

View 14 Replies View Related

Tables :: Record Cannot Be Deleted Or Changed Because Table Include Related Records

Oct 16, 2012

Three tables:

Employee, Sessions, EmployeeSessions.

Many sessions can have many employees - thus the joining table has been included.

When trying to delete an employee from the database using a form, I encounter the error:

The record cannot be deleted or changed because table 'tblEmployeeSessions' includes related records

Is there a problem with my table relationship structure? Or is it 'correct' that as the employee is supervising a session he/she cannot be deleted as this would interfere and maybe mess up the session record?

View 2 Replies View Related

Modules & VBA :: Data Type To Be Changed In Import

Sep 1, 2014

I have excel, which i want to import in Access, but i need data type to get changed as text when imported, how can i do that?

View 2 Replies View Related

Modules & VBA :: Keep Track Of When Form Data Has Changed

Aug 16, 2014

I want to keep track of when data in a form was last changed.I only need to track this when the form is closed. not every time a record is changed.

View 5 Replies View Related

Modules & VBA :: Count Number Of Records With Date From A Table

Sep 24, 2014

I have a table which specifies the delivery date

I have a from that allows you to choose a year and a month.

I have an unbound textbox which I wan to display the count

I want to be able to count all the records from a table with the year and month specified in the comboboxes and display this in the texbox.

View 4 Replies View Related

Modules & VBA :: Loop In Batches / X Number Of Records At A Time

Jul 4, 2015

I have a form which uses a loop command to output reports as a PDF. The reports take a bit of time to produce and the record set could contain 100-150 records. Any way that you can split the recordset down into batches. Maybe have a button which creates 1-20 and another 21-40 and so on.

View 1 Replies View Related

Modules & VBA :: Create X Number Of Duplicate Records According To A Field On Subform

Jun 13, 2013

I have a code that works great from the parent form but I decided to change the format and call it from a lostfocus event in the subform instead. Now I keep getting error 3314:"You must enter a value in the tbGuests.LastName field".

The code should copy the parent form fields and create x number of duplicate records according to a field on sub-form. It then runs an append query to add the information from the subform.

Code:

Private Sub GuestsInParty_LostFocus()
Dim partymsg As Integer
Dim dbs As dao.Database, rst As dao.Recordset
Dim F As Form
Dim intHowMany As Integer
Dim intCounter As Integer

[code]....

View 1 Replies View Related

Modules & VBA :: Focus To Be Set To First Control Without Displayed Record Being Changed

Jul 31, 2013

On a form (default view: Single), I have a bunch of bound controls that display one record at a time from tblMain. I have a bunch of unbound controls as well (buttons).

If the user tabs through all the controls, reaches the last one (btnLast), and presses tab again, the focus is set to the first control (btnFirst) and the bound controls change to display the next record. I just want the focus to be set to the first control without the displayed record being changed.So I set up an "If" statement in Private Sub btnFirst_GotFocus()

Code:

If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If

But btnFirst gets the focus when the form opens, so Screen.PreviousControl spits out an error.I've accommodated this like so:

Code:

On Error GoTo ErrorHandler
If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If
Exit Sub
ErrorHandler:
Exit Sub

View 2 Replies View Related

Modules & VBA :: If Combo Value Changed Make Checkbox True

Feb 20, 2014

I have combo box call "supervisor" and check box call "supervisorchange" basically want to make supervisor change to true if combo box is change which I have made code you can see below it work's

Code:
Private Sub Supervisor_Change()
If Me.Supervisor = "" Then
Me.SupervisorChange = False
Else
Me.SupervisorChange = True
End If
End Sub

right now my problem, prob easy fix for you access experts

If the supervisor combo box is empty and user inputs a supervisor I would like the supervisor change check box not to change to true

only if the user changes it after the first input I would like the supervisor change check box to become true

View 2 Replies View Related

Modules & VBA :: Using Temp Variable To Append Specific Number Of Records To Table

May 29, 2014

I need to extract a specific number of records into a table using a MakeTable or Append command using a temp variable, e.g. TempK&SA. Previously on the forum I was shown how code could be added to the OnOpen function to use a temp variable to select a specific number of records to report. ACCESS does not have the OnOpen function in the design view of a query like in the report. It does allow a SELECT TOP but only with fixed variables or percents (e.g. 25 in the code below).

The beginning code for the make table query (where 25 is the number of records added) is:

INSERT INTO [Output] ( RndNo, PointBiserial, BloomsTax, DateRevised, Exam1, Status, Exam2, Exam3, Exam4, [NCCPAKnowledge&Skills] )
SELECT TOP 25 TestBank.RndNo, TestBank.PointBiserial, TestBank.BloomsTax, TestBank.DateRevised, TestBank.Exam1, TestBank.Status, TestBank.Exam2, TestBank.Exam3, TestBank.Exam4, TestBank.[NCCPAKnowledge&Skills], *
FROM TestBank
WHERE (((TestBank.PointBiserial) Is Null Or (TestBank.PointBiserial) Between [TempVars]![TempPointBiserialLow] And .....

how to modify the code to allow a temp variable to determine the number of records to append to another table would be gratefully received. (This process then is repeated for a total of 7 append tables with different temp variables.)

View 7 Replies View Related

Modules & VBA :: Updating Or Adding Records To Form - Find MAX Of Number Portion

Jun 28, 2013

I want whenever I'm updating or adding records to my form, the ID automatically take the value of the previous ID and increment it by 1.

The field type is text (mixed with number) - PM0000000.

I've done some research, what I understand is that I need to:

-do a lookup and
-find the MAX of the number portion.

Name of form - Payment
Name of table - Payment
Name of field - payment_id

I tried these, but to no avail...

Private Sub payment_id_Click()
payment_id = DLookup(("[payment_id]", "Payment", "[payment_id]=Forms![Payment]![payment_id]-1")payment_id + 1)
End Sub

[Code] .....

View 8 Replies View Related

Modules & VBA :: Count Number Of Unique Records Based On Range Of Date

Jan 19, 2015

Code:
' count records in query
Dim rs As DAO.Recordset
Dim db As Database
Dim strSQL As String
Dim beginDatum As String
Dim eindDatum As String
Set db = CurrentDb

[code]....

View 4 Replies View Related

Modules & VBA :: Audit Trail Returning Primary Index Of A Record Changed

Apr 24, 2015

After a lot of reading and consolidating VBA codes for audit trail.How My Audit Trail Works..A module was made for a function named as "Changes" .Then inserted into before update event of a form where I will do the editing of the records.Then I made a table named as Audit.Inside this table I made all the fields I needed such as:

*AuditRecordId[autonumbered]
*FormName[The name of the form for editing]
*Index[The record ID of the record being edited]
*ControlName[The Field being edited]
*DateChanged[Date change was done]
*TimeChanged[Time change was done]
*PriorInfo[for the old value of data being changed]
*NewInfo[For the new value of data changed]
*CurrentUser[The user base on log in form that was set to Global into another module]
*Reason[The reason for changing for future references]

And Here is the Function Code:

Code:

Option Compare Database
Option Explicit
Function Changes()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strCtl As String
Dim strReason As String

[code]....

This audit trail function is valid only for one(1) form, due to the limitation of

Code:
Screen.ActiveForm.Controls("SUP ID").Value

where "SUP ID" is the primary key of the record being updated/Change, so if there are Five(5) tables that needs audit trail, there will be also Five(5) forms, as well as Five(5) Function Changes namely; Changes(), Changes1(),Changes2(),etc... because all the table do have their own sets of primary Key.

Is there a shortcut, in such a way that the "rs!Index" will automatically return a value, equivalent to the Primary Key/Record Id of the record being updated/change, given that there are different updating forms for each table to be updated?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved