473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

having troble with my task# auto population.

I have a access database that I have been using for years, but I lot my codes to help me change the New task for the year. when I start typing in he info it should auto populate a new year and task number like (2018-0001) but it is not work. this is the code that is there.

Expand|Select|Wrap|Line Numbers
  1. Private Sub New_Task_Click()
  2. On Error GoTo Err_New_Task_Click
  3.  
  4.     Dim curnum As Integer
  5.     Dim curyr As Integer
  6.     'DoCmd.GoToRecord , , acNewRec
  7.     Dim rcrds As Recordset
  8.     Set rcrds = CurrentDb.OpenRecordset("SELECT [Task #], Classification FROM [Tbl:Geo Task Database] ORDER BY [Task #] DESC")
  9.  
  10.     curnum = Right(rcrds![Task #], 4)
  11.     curyr = Left(rcrds![Task #], 4)
  12.     rcrds.AddNew
  13.  
  14.     If Year(Now) = curyr Then
  15.     rcrds![Task #] = Year(Now) & Format(curnum + 1, "0000")
  16.     Else
  17.     rcrds![Task #] = Year(Now) & "0001"
  18.     End If
  19.  
  20.     rcrds![Classification] = "UNCLASS"
  21.     rcrds.Update
  22.     Me.Requery
  23.     DoCmd.GoToRecord , , acFirst
  24.  
  25. Exit_New_Task_Click:
  26.     Exit Sub
  27.  
  28. Err_New_Task_Click:
  29.     MsgBox Err.Description
  30.     Resume Exit_New_Task_Click
  31.  
  32. End Sub
Feb 23 '18 #1
1 1285
twinnyfo
3,653 Expert Mod 2GB
shaqfu01,

Welcome to Bytes.

To say that your code does not work is not very helpful. Exactly what is not working? Is the code generating an error? If so, what error? If not, is the code producing an unexpected result?

This information will help us to understand and troubleshoot your problem.

Thanks!
Feb 26 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: janet | last post by:
HI, I had a question on auto-commit in DB2 EEE V8 on AIX V5. Here is my example.. there are two script A.sh , B.SQL A.sh is following:
2
by: Kenny G | last post by:
Currently I have four datetime fields: DteTimeNotified DteTimeStarted DteTimeCompleted DteTimeReported Each of these fields contain the input mask 99/99/00" "00:00;0 This gives me a short...
1
by: Scott | last post by:
Is there an easy way of having a form auto sized to suit a particular screen res? Eg, If a package is designed using 1024*768 but someone want's to use it at 800*600 can it be automatically...
0
by: Brian Henry | last post by:
I'm sure some of you ran into this already and wondered how to fix it. When you Have a solution that contains solution folders (the partially transparent folders that can hold groupings of...
2
by: des-sd | last post by:
Access Experts, Please help! I have looked through ref. manuals, Google Groups on "Auto Populate", and I am still lost. Problem #1 My DB is 2 relational tables of (1) sales transactions of,...
14
by: neonman14 | last post by:
Hello I am in Intro to Java Programming and I am having problems with assignment. The Homework assignment is called Population. Population Write a program that will predict the size of a...
1
by: patilanjana | last post by:
Hi, I am getting above mentioned errors. Checked msdn, read the comments but I fail to implement it. Please help. Error is regarding using the new and delete operators. Although I do write...
1
by: glasssd | last post by:
Hi, I was hoping someone might have some ideas on how I can hack around a problem I'm having with the auto-complete feature of the ComboBox. I have a data entry application that uses a pair of...
1
by: brittb | last post by:
Hi there. I'm a complete novice trying to create my first database, so please feel free to treat me as such. I'm trying to track specimens coming through my lab, which will go through several...
1
by: evenstar | last post by:
I'm having trouble with auto and decltype. void f(const vector<int>& a, vector<float>& b) { typedef decltype(a*b) Tmp; for (int i=0; i < b.size(); ++i) { auto p0...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.