I found an old post by sbaxter that appears to give me what I need. The problem is that there must be something I am not understanding.
Right now I am getting an "invalid use of null" warning, even though I know that there are values out there.
Everything is on SQL server and I am using an adp file.
The goal is to take the year from the "date received field." and check the table for all records that match. Then get the maximum "Claim_Number_Increment" value from the table. My new increment value will become one higher than that. (I haven't gotten to the point of handling the reset to one when there are no values year - one thing at a time.)
Here's my code, adapted from sbaxter's example:
Code:Dim dtCurrentYear As DateDim s As StringDim intIncrement As IntegerDim db As New ADODB.ConnectionDim rs As New ADODB.RecordsetSet db = CurrentProject.ConnectiondtCurrentYear = Year(Me.txtDateReceived) s = "SELECT MAX(Claim_Number_Increment_I) As 'Increment' FROM dbo.CSF_Claims_T " _ & "WHERE Year(Date_Received_DT) = " & dtCurrentYear Set rs = New ADODB.Recordset rs.Open s, db, adOpenStatic, adLockOptimistic intIncrement = rs.Fields("Increment") Set rs = Nothing Me.txtIncrement = intIncrement + 1
Somehow, it is telling me that I have no values - in reality, I should be getting a 4.
I was searching for a solution to this problem and found a thread called "Changing page numbers?" from 2012 but it is not clear : [URL] .....
I have two issues with my report. The first is the page number. The print control on the correlating form allows the user to print a range of reports based on the TransmittalID number. TransmittalID #1 is a 2 page report and #2 is a single page report but when I choose print from ID 1 to 2 the page numbering says page x of 3 instead of page 1 of 2 and 2 of 2 for ID #1 and page 1 of 1 for ID #2. Following along the thread above I managed to reset the page numbers to restart at 1 for each page but that is as far as I got. I'm not sure where to enter the code that was provided.
My second problem is that the report footer contains a signature line; however, printing a range is resulting in this only showing on page 3. How do I set this that for each new ID# start a new report. I've tried force new page, inserting page breaks but no luck.
Hi, I have the need to restart the autonumber field for each record back to 1 so I can see how many times a customer has been contacted. I have a table which contains the customers details, and another table to capture the contact history (currently empty until the customer is contacted and it is populated). The form I am using contains a subform (the contact history) which is where I need the autonumber to restart from 1 for each customer. Basically I only want 3 records/contacts for each customer on the main form and I want the subform to show what contact number I am up to (either 1, 2, or 3). I hope this makes sense!
Here what I want to do. I want to use the autonumber facility which will restart by itself yearly in the following way. 1/2004 2/2004 3/2004 4/2004 . . 1/2005 2/2005 3/2005 4/2005
hi, after debug some functions in a form, my table has 15 records, after I deleted them my autonumeric field doesn´t start in 1, how can I restart to number 1?
Using code on a form to look for a null value for a field on my form. For soem reason this isn't working. I'm checking for a null value in the field on the form. Even if the ClosedDate field is null it still shows the Not null message box. Am I doing something wrong? Thanks
Private Sub Command102_Click() If Me.ClosedDate = Null Then MsgBox "Null" Else MsgBox "Not Null" End If
Hello I try to print some reports one-by-one using a button . In the no_data event of each form I've added a message box informing the user that the form will not be printed due to the lack of records. Everything is ok so far. However, after my message box appears and I press ok, a run-time error '2501' occurs informing me that the "openreport action has been cancelled" and promting me to end/debug the vbcode. Is there a way to by-pass this "error" and carry on without having to end/debug the project? Thank you in advance
I have an append query which fails due to validation rules. There are no field validation rules, only enforced table relationships. There is an autonumber field which I am omitting from the INSERT and SELECT clauses in the hopes that it will take its next value.
How do I determine which fields are causing the problem? I have changed the query to a simple SELECT and manually typed in the resulting values with no problems. Note that ALL records I am attempting to add fail the rules.
I have a table which will contain project information, and want the ID field, which auto assigns a unique number to each record, to be formatted like this P12-001, where 12 = the last two digits of the year the record was created. I know that if I type into the format field "P"00"-"000 i get the ID number in the format I want, but cannot figure how to get the first two zeros, to be the date format.
Further, I would like the ID numbers to restart from 1 each year, so this year this first project, P12-001 and may run through to P12-063, then the first project I enter next year to start P13-001.
I have developed quite a large database for my company to register complaints on. At certain points, a user may encounter an error when a procedure goes wrong and I want to know if there is a way I can remove the option to debug when it pops up saying End or Debug. Some of the users are using Access Runtime and I know that this will not allow them to debug but for those that are Full version users, I need to prevent this....prying fingers! :-)
I am using Windows 8.1 64 bit system. Into attached access file (OfferStudy.accdb) ,trying to load an activeX TreeView control by defining into a form module. First, I created an empty form and activeX Treeview control.When I define tv variable As TreeView as created in application, it is changing as Dim tv As treeView instead of TreeView. After my code is completed,an error message ("user-defined type not defined") is returning as shown in attached (DebugError.png)file.
I suppose that there is some conflict on creating activeX control on my Access 2013 application.
I have one main table containing most data, that table stores data which is identifies by a unique ID (currently 1-96000), there is also an issue number, I need another numbering system per issue (so you could have issue 166, record 26), any ideas?
Hi I obviously have a table with records in it sorted in assending order. What I need is to know how to make it add into one of the table fields the number it is in the table. IE
Name Time Position Number Mr Jones - 12:30 - 1 Mr Evans - 12:45 - 2
So if i added 12:35 it would change mr evans position number to 3 and make the new record position number 2.
I want to distribute certain materials (found in a query) to several warehouse locations in a sequential order.
So the first found material needs to be put in warehouse location 001, the second found material needs to be put in warehouse location 002, etc.
How can I number the lines in a query?
I don’t want to run a create-table-query with an auto number field because the warehouse locations are limited and every time the query runs the numbering has to start at 001.
Shall be grateful for clarifications for these two :
1. I have two fields - TheYear (set to take the current year) and another for sequential numbering. In fact I created this to replace the autonumber field. As suggested by a member I created a Generate button with the criteria as under
Private Sub Generate_Click() If IsNull(Me![NumFld]) Then Me![NumFld] = Format(Nz(DMax("[NumFld]", "[DiaryTable]", "[TheYear]='" & Year(Date) & "'"), 0) + 1, "00000") End If Me![NumFld] = Format([NumFld], "00000")
End Sub
It works fine. and when the year is changed, the numbering starts from 1 again. My question is how do I make it to auto generate the number so that the user doesnt have to click the Generate button everytime to get the number. Suggestions please.
2. Is it possible to change this sequential numbering midway i.e. to start from a different number and increment by one?
We have a part numbering system that is currently like this, 11Y22 where 22 increments by one until it gets to 99 where it then goes back to 0, once it goes to 0 the letter increments to Z in this case, now once the last three characters get to Z99, then the 11 gets incremented eg, 11Z99 will become 12A00. Hope that is clear :)
My question is, can this system be implemented into the auto numbering in Access?:confused:
Hi there I'm sure that this must be easy, so go gently on an old codger! I have a query for which I wish to add another field containing a running total of the number of records produced by the query (after all sorting etc.).
In other words, if my query produces n records, that new field would contain the value 1 in the first record, 2 in the next and so on to n.