473,399 Members | 3,038 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,399 software developers and data experts.

Code problem relating to custom string

damonreid
114 Expert 100+
I have a drop down list that takes a "Stock Type" and then assigns a new code based on that stock type to a field called "Stock ID".
The Idea is to have XXX-0001 as the first ID and XXX-0002 as the second. Then you could have a BXA-001 as well. I have done this several times before but now I get an error when I try.

Run-Time Error '2001'
You Canceled the previous operation.

Code is show here.
I have a query "SectionCodeQuery" that filters by Stock Type based on the same form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Stock_Type_AfterUpdate()
  2.  Dim strProdCode As String
  3.  Dim strCriteria As String
  4.  
  5.  If Me.NewRecord Then
  6.   strProdCode = Me.Stock_Type.Value
  7. 'Increment the lngNum field by One, if field is Null, set as 0 then add 1
  8.   Me!CodeNumber = Nz(DMax("Right(strID,4)", "SectionCodeQuery"), 0) + 1
  9. 'Customize the ID then attach the incremented
  10.   Me!Stock_ID = Me.Stock_Type.Value & "-" & Format(Me!IngNum, "0000")
  11. Else
  12.   Me!Stock_ID = Me!Stock_ID
  13. End If
  14.  
  15. End Sub
Aug 17 '07 #1
1 1102
FishVal
2,653 Expert 2GB
I have a drop down list that takes a "Stock Type" and then assigns a new code based on that stock type to a field called "Stock ID".
The Idea is to have XXX-0001 as the first ID and XXX-0002 as the second. Then you could have a BXA-001 as well. I have done this several times before but now I get an error when I try.

Run-Time Error '2001'
You Canceled the previous operation.

Code is show here.
I have a query "SectionCodeQuery" that filters by Stock Type based on the same form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Stock_Type_AfterUpdate()
  2.  Dim strProdCode As String
  3.  Dim strCriteria As String
  4.  
  5.  If Me.NewRecord Then
  6.   strProdCode = Me.Stock_Type.Value
  7. 'Increment the lngNum field by One, if field is Null, set as 0 then add 1
  8.   Me!CodeNumber = Nz(DMax("Right(strID,4)", "SectionCodeQuery"), 0) + 1
  9. 'Customize the ID then attach the incremented
  10.   Me!Stock_ID = Me.Stock_Type.Value & "-" & Format(Me!IngNum, "0000")
  11. Else
  12.   Me!Stock_ID = Me!Stock_ID
  13. End If
  14.  
  15. End Sub
Hi, there.

Your code is not clear.
Is Me!CodeNumber the same as Me!lngNum?
And what does it mean - Me!Stock_ID = Me!Stock_ID
And I can only guess what is happening behind the scenes in "SectionCodeQuery", but are you sure it filters records where strID starts from Me.Stock_Type?
Aug 17 '07 #2

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

Similar topics

25
by: delerious | last post by:
I see some code examples like this: <DIV onmouseover="this.style.background='blue'"> and other code examples like this: <DIV onmouseover="javascript:this.style.background='blue'"> Which...
8
by: Bshealey786 | last post by:
Okay im doing my final project for my first computer science class(its my major, so it will be my first of many), but anyway im a beginner so im not to great with C++ yet. Anyway this is the error...
9
by: Steve Jorgensen | last post by:
First, an example - today, I wanted to print out the parameter values in a querydef object at a break point in the code for subsequent manual debugging of the query. In the past, I would have had...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
39
by: Abubakar | last post by:
I want to get characters for given ascii codes. Dont wanna use the CHR or ChrW functions. What r the .NET equivilents of the Chr & ChrW functions? Regards, Abubakar.
1
by: Pepe | last post by:
Hi, I have created the "Hello World" web service with one web method on it "HelloWorld" (yes the tag is there). I have deployed the web service to a Windows 2003 server, then I create a new...
5
by: Jeff | last post by:
ASP.NET 2.0 This code crashes. It generate this error: Value cannot be null. Parameter name: type I've created some custom web.config settings and this crash is related to accessing theme...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.