Modules & VBA :: Autofill Cell Based On Previous Record Value
Aug 26, 2014
I am trying to write some vba code to auto fill a cell's value based on the value of the cell in the previous record (In a datasheet form) i.e. if the value in record one was '1' and the down-arrow key was pressed then the value '2' should be entered into the new ext record
I have written some pseudo-code to show what I am trying to accomplish:
if keydown = down-arrow and current cell contents isnumeric then
Cval = current cell contents
if current record = last record then
create new record
move down 1 record
set cell value of new record to cval+1
else
move down 1 record
if cell value = null then set cell value of record to cval+1
end if
end if
View Replies
ADVERTISEMENT
Dec 27, 2005
I am trying to autofill a field based on the value of a previous field on a filtered form. I think the fact the records are filtered is throwing me off. Any help for me?
View 9 Replies
View Related
May 8, 2006
I'm new to this forum and I'm sorry if this is a repeat question...I looked in previous threads, but could not find my particular questions.
Here's the situation:
I enter a bird name in my form (I've set up a combo box of 200 choices). Each bird species has an max and min possible wing measurement. So when I enter a newly captured bird in my form, the wing measurement must fall between the minimum and maximum for that particular species. I've done similar things with cascading combo boxes, but can't figure out how to the do a between-type statement in this situation.
Thank you much,
Erik
LSU, Baton Rouge, LA
View 9 Replies
View Related
Jun 30, 2015
I have my Assets form and the primary key is the ChargerID, in this form I have an "Add New Job For This Asset" button, which opens up the Jobs form at a new record.
How do I make it so that the ChargerID field is automatically filled with whatever the previous record was instead of being blank.
For example if I have Charger12345 open in the Asset form, I'd like to click the Add New Job button and it automatically have Charger12345 in the ChargerID field of the Jobs form.
View 5 Replies
View Related
Aug 15, 2015
I want to be able to pre-fill records with information based on a form every day for each client. This needs to display in a datasheet view showing all clients for each location.
Each day the subform needs to show the expected results of that day's activity with clients if all default conditions are met. (i.e. client receives a call that day based on expected conditions calculated in a form for that day).
View 3 Replies
View Related
Apr 30, 2007
I need a way to dynamically store a particular value in "field_2" of the CURRENT record depending on whether or not the value of "field_1" of the CURRENT record is identical to the value of "field_1" of the PREVIOUS record within the same table. The table is sorted on "field_1".
So, if the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is also "ABC", then store a value of "PPP" in "field_2" of the current record. IF on the other hand, the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is "XYZ", then store a value of "WWW" in "field_2" of the current record.
I have a report that will use these results to count only the number of records that have a "WWW" in "field_2".
Is this doable, maybe in a query somehow?
I should add that whatever the solution, it needs to be compatible with Access 2000.
View 1 Replies
View Related
Nov 17, 2010
create a macro that automatically fills in the next invoice number in sequence",,I'm assuming this macro would look at the value of the previous record and add a one to itI don't want to use a AutoNumber field as I might need
(a) to modify value or
(b) need to skip numbers.
View 8 Replies
View Related
Sep 1, 2004
Okay,
What I need to do is two fold. I have a table in which I track clinets coming in and using our services.
Question 1: I want to be able to have a a date field default to the date I first type in when I open the form and remain there in all
subsequent records till I change it. The data is only entered once a week and we usually have 400 client visits per week
with about 75 - 120 per day. So it kind of gets repeatitive to keep typing in the date. I am aware of the CTRL+', but the staff who use this database do not even want to do that.
Question 2: Next problem....How would I create an autocorrect function that will automatically fill in a name...i.e. I begin to type jo and it will automatically fill in the hn...but I want the values to come from previously entered data from past records, similar to the way Excel does it in spreadsheets.
Any Ideas would be greatly appreciated.
View 1 Replies
View Related
Apr 3, 2008
I'm trying to update an imported table from an excel spreadsheet with missing details. The table's records are in order so I just need to fill in a blank field with data based on the previous one as shown.
ID Name Location
1 Bob London
2 Larry
3 Harry
4 Jerry Glasgow
5 Paul
6 John Southampton
I need to fill in the location blanks simply with the last location details, so records 2 and 3 with London and 5 with Glasgow. Is this easily done or would I need to pull all the data into an array and work on it there?
I've tried searching for an answer but haven't had any luck.
View 1 Replies
View Related
Feb 4, 2005
I'm having trouble with a tricky conditional format in a continuous subform.
The criteria is based on field [GroupNo] when it changes (increases) which are always listed in numerical order.
Basically all I want to is for the text box colour to alterante (eg blue & yellow)when GroupNo changes value
So it would look something like this....
Group NoID (highlight colour)
1 (yellow)
1 (yellow)
1 (yellow)
2 (blue)
2 (blue)
2 (blue)
3 (yellow)
3 (yellow)
etc etc
btw, although values will always be in order they may not all be output, so it's not just case of odd, even, odd, even (that would be too easy!)
I can retrieve the Previous Record's GroupNo value (via a function) in another text box and compare current GroupNoID with this in the Format Expressions and manage to change the colour, but it won't sustain this new colour for the subsequent same GroupNos, obviously as the values have changed.
So how can I....
Change the colour when the value changes.
Keep this new colour until it the value changes (increases) again.
Many Thanks
View 14 Replies
View Related
Jun 17, 2013
I am creating a database for an annual golf tournament. Part of this is to allocate players to play off together at certain times.
I have a form bound to a table called tblteeofftimes. This form has five fields (continuous form) - four of which are comboboxes whereby user selects each player for the record (who will play together). The other textbox has the tee off time. the first tee off time will be allocated by user eg 7:00 am.
My problem is I need to update each ensuing record with a new time slot at 7 minute intervals. Rather than have the user populate the form themselves I would prefer this be done authomatically as the user moves onto the next record.
View 12 Replies
View Related
Jan 22, 2015
There is a form which the user fills in 8 fields and saves it. Once saved, a new record opens.
However, I want to modify the save button to save the previous record and display a new record with only a limited no of fields to display from previous record, say 4 fields display from previous record, and the user fills the remaining 4 and saves it. Thus, the save cmd should continue to display 4 fields from the previous record.Already tried below code for save button but it displays all data of previous record as it is, doesn't display blank space for combo.118 and text2
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acPrevious
Combo118.Text = ""
text2.Text=""
View 1 Replies
View Related
Jun 29, 2015
I have a column "CAT" each time that CAT switches between 0 and 1, I would like my query to auto-create a "grouping" and increment the group by 1. What I am looking for is the output as shown below.
ID CAT GROUP
67 0 1
68 0 1
69 0 1
70 1 2
71 1 2
72 0 3
73 0 3
74 0 3
75 0 3
76 1 4
77 1 4
View 6 Replies
View Related
Aug 2, 2013
I have a table full of meter readings. I want to have a field called consumption which looks at the reading just entered for that month and then subtracts the previous months reading for that meter which leaves the consumption.
Can I get a formula that can work this out automatically?
View 3 Replies
View Related
Jul 16, 2015
I was wondering if there is a code for Next and Previous record in a form but for a specific value.
Example: I have a customer that has a specific ID and that customer has a list of orders that all contain that ID. When I open a form for orders I would like to be able by using Next and Previous record buttons to be able that was to move only through records of that customer not the whole list of orders for every customer.
View 1 Replies
View Related
Oct 4, 2013
I have partially done it using PrevRecVal module I found on the web.
I created what I need to do in Access in Excel first, the problem doing this in Access (for me) is I need to refer to the results in the previous record, PrevRecVal worked but I need to finish if possible.
The main report holds client policy data of which InvestAmount is used to start the calculation of the sub report, the data entered to run the calculations on the subreport would be
QtrDate
CurrentUnitPrice
The Excel spreadsheet is attached ....
View 10 Replies
View Related
Jun 22, 2013
It is a continuous subform (Names: Form = ClientUpdate / Subform = ClientUpdateSub.
All of the data implicated here is direct and in the subform's query table including the button we want to program.
(This is my example but it wont stay in columns in this "post box" )
IDNo App _ID App_Freq App_Date GetDates Action_Date
22 18 56 21-Jun-13 BUTTON 14-Jun-13
21 19 56 16-Aug-13 BUTTON 9-Aug-13
*
The GetDates Command BUTTON should generate the red data above, like:
Private Sub GetDates_Click()
Go to a new record
Go to the field App_Freq and fill it with:
Copy/paste the data from the field of the same name in the previous record
Go to the field App_Date and fill it with:
data based on this calculation using the PREVIOUS record fields: App_Date + App_Freq (which are days)
Go to the field Action_Date and fill it with:
data based on this calculation: App_Date (of current record now filled out - step above), minus 7 (days).
End Sub
That's it!
All the dates format is set to medium date. An error message should come up in case App_Freq is empty, for example
Also note that the data can be manually changed at any time and should not revert to its last calculation. The button only generate data into a new record.
View 14 Replies
View Related
Jun 5, 2013
I want subtrack a value on the current record from the previous record and display the result in text box in subform datasheet. This is done during data entry. The calculation works most of the time and randomly it returns the wrong value. I have the code in an after update event after I enter a number. Here is what my code looks like:
sysHopSpacing = Abs([sysHop1] - DLookup("[sysHop1]", "tblSystemConfiguration", "[sysBaseNumber]=Forms![frmTempestCoordination]![frmSubSystem]![sysBaseNumber] - 1 "))
This is how I generate the sysBaseNumber
sysBaseNumber = Nz(DMax("sysBaseNumber", "tblSystemConfiguration", "sysAccountID=" & Forms!frmTempestCoordination!accAccountID), 0) + 1
I am using DMax so I can keep the subform records with the parent form record.
My results are inconsistant:
This is what I want the subform to do when subtracking from the previous record
syshop1 sysHopSpacing
5
20 15
30 10
Instead I get a result that does not make sense like this:
sysHop1 sysHopSpacing
5
20 15
30 4
I cant trace it down.
View 14 Replies
View Related
Nov 21, 2006
i have a table of articles. A field in the table is ArticleSubject
the ArticleID is made up of 3 letters then 3 numbers. i want the 3 letters to be something according to the subject
for example i want the first 3 letters of the ArticleID to be MAT*** (* is a number) if the subject is Maths
or ENG*** if the subject is English
the subject is picked from a listbox in the same record
how would i do this in a table . i am reluctant to use append or update queries.
but will do so if its the only way.
View 4 Replies
View Related
Sep 18, 2014
I'm trying to create something like an online banking view that shows the running balance as each transaction occurs. I have tblTransactions with fields AccountNumber, ItemDescription, and TransactionAmount. I'm trying to create something that shows these three fields and a fourth field with the running balance.
So if I initially deposit $100 it will show the first record with TransactionAmount = $100 and RunningBalance = $100. Then the next transaction will subtract the Transactionamount for the new record from the RunningBalance from the previous record to get the RunningBalance for the new record. So if I make a purchase for $2, the AvailableBalance for that record is $98. Is this possible with a query? Here's a picture to describe what I'm talking about ....
View 3 Replies
View Related
Jul 9, 2014
I have a database (small one which i designed)
I have created all the tables.
I then have a "form" called July-14 (i need to figure out how i can automatically replicate this form for new months)
Anyway, one of the cells pulls out a product name (using the lookup wizard), i then have a cost cell which i would like to populate automatically based on the product name.
The table July-14 links to a product table which has ONLY those 2 attributes in there, the name and cost.
How do i get it to pull the cost automatically.
View 5 Replies
View Related
Sep 28, 2004
I am learning Access fairly quick, but still a newbie and stuck on an autofill problem. I have read everything I could find and it seems there may be code involved, which I'm not sure about.
The problem seems simple enough: I want to populate field "Rate" in the table "Services" based on the selection from a dropdown menu referencing ClientID in the Clients table. Specifically, my form uses a drop down menu to select ClientID for the Client table to associate with fields in the Project table and I have imbedded another form at the bottom which contains fields from the Services table including the Rate field I want autofilled based on the ClientID selection. Here are the tables and fields I'm working with...
...table...
Client
...fields...
ClientID (PK)
Rate
<and more>
...table...
Project
...fields...
ProjectID (PK)
ClientID
<and more>
...table...
Services
...fields...
ServicesID (PK)
ProjectID
Rate
<and more>
Please be easy on me if this is a simple problem. Thanks!!!
View 7 Replies
View Related
Aug 21, 2013
I have generated a report with my entire list of personnel, and I have created a column that generates thier age based of another column using this:
=DateDiff("yyyy",[Birthday],Now())+Int(Format(Now(),"mmdd")<Format([Birthday],"mmdd"))
Now my question, im trying to hide the rows of those who age is older than 26. If thats not possible maybe highlight the entire rows of those under 26, i used conditional formatting to highlight the age, but not the entire row.
View 1 Replies
View Related
Apr 29, 2006
I have a main form for a tblCommittee and a subForm 'sfCommitteeOfficer' that will eventually take an entry or show -if its existing, a list of Committee officials. The officials come from a 'tblMembers'. There are too many members to use a drop down list box to select the MembNumber. What I wanted to do was be able to enter the MemberNumber in a txtBox 'MembID' on the form in the row containing Memb#, MembName, Position i.e chairman, Date elected Date retired, and have the members name automaticlly entered into the field MembName of the subform to limit the amount of entering the user has to do!
Is this possible? I have a tblCommiteeType with key field CommitteeID, and foreign Key MembId, so I dont think I need a tblCommitteeMember because names are already stored in tblMembers.
View 3 Replies
View Related
Sep 13, 2012
I have a review pop up form (frmReview) where a user selects their Name (StaffID), the type of check they are doing (QuailtyType), and the client they want to do it on (clientID). When they press on the 'do review' command button from this form another form opens (frmReviewDetails) which shows the client they selected from the frmReview form as well as a its subform which shows all the sessions that have been entered for this client along with some fields that have not been complted yet regarding review data. I am trying to have it so when they check the 'review check box' in this subform that today date auto populates in the Review date field (this is currently working). I also want it to auto enter the staffID that they selected on the the initial frmReview form.
This is my currunt code:
Private Sub Rev_AfterUpdate()
If Me.Rev = -1 Then
Me.[RevDate] = Now
Else: Me.RevDate = Null
End If
End Sub
I really don't want a staff to have to enter their name each and every time they check the review box. Not all box's are going to be checked, so it needs to be on a record to record basis.
View 2 Replies
View Related
Aug 30, 2014
I got a problem about form designing. i need to disable my Close Command button while my subform Price cell is null and enable the Delete button.
And while delete button is pressed the delete action occurred and close button enabled.
View 12 Replies
View Related