473,325 Members | 2,774 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,325 software developers and data experts.

Dim me as stubborn!

Hi!
I seem to have some very empty spaces in my head.
Could you help me fill them?

Dim intNumber As Integer
'Get value from field in table that is text
intNumber = DMax("[KeyNo]", "tblInvoiceDetails") + 1
'Fill KeyNo-field as the user enters the field
Me!KeyNo = intNumber

So what I'm trying to do is having a number be produced
as the user enters the field in subform.

Now, the number is already there, say: 100020041234567890,
and I want it to increase by one everytime I enter the KeyNo-field
in the subform.

However...I keep getting: "Type mismatch" - RunTime Error 6

What's wrong?
Nov 13 '05 #1
4 1554
Try:
Dim lngNumber As Long
'Get value from field in table that is text
lngNumber = CLng(DMax("[KeyNo]", "tblInvoiceDetails")) + 1
'Fill KeyNo-field as the user enters the field
Me!KeyNo = lngNumber

"Geir Baardsen" <ge***********@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
Hi!
I seem to have some very empty spaces in my head.
Could you help me fill them?

Dim intNumber As Integer
'Get value from field in table that is text
intNumber = DMax("[KeyNo]", "tblInvoiceDetails") + 1
'Fill KeyNo-field as the user enters the field
Me!KeyNo = intNumber

So what I'm trying to do is having a number be produced
as the user enters the field in subform.

Now, the number is already there, say: 100020041234567890,
and I want it to increase by one everytime I enter the KeyNo-field
in the subform.

However...I keep getting: "Type mismatch" - RunTime Error 6

What's wrong?

Nov 13 '05 #2
If the number provided by the OP as a sample, is actually representative of
the data, there's another problem. That is way beyond the capacity of a 4
byte integer (Long). Another example of why "smart" keys are a bad idea.

"ByteMyzer" <sb*@nospam.news.chi.sbcglobal.net> wrote in message
news:Aq*****************@newssvr17.news.prodigy.co m...
Try:
Dim lngNumber As Long
'Get value from field in table that is text
lngNumber = CLng(DMax("[KeyNo]", "tblInvoiceDetails")) + 1
'Fill KeyNo-field as the user enters the field
Me!KeyNo = lngNumber

"Geir Baardsen" <ge***********@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
Hi!
I seem to have some very empty spaces in my head.
Could you help me fill them?

Dim intNumber As Integer
'Get value from field in table that is text
intNumber = DMax("[KeyNo]", "tblInvoiceDetails") + 1
'Fill KeyNo-field as the user enters the field
Me!KeyNo = intNumber

So what I'm trying to do is having a number be produced
as the user enters the field in subform.

Now, the number is already there, say: 100020041234567890,
and I want it to increase by one everytime I enter the KeyNo-field
in the subform.

However...I keep getting: "Type mismatch" - RunTime Error 6

What's wrong?


Nov 13 '05 #3
OK!
Give me a suggestion: the number I'll produce is being made of three
details:

1. The customer number (1000)
2. The actual year (DatePart("yyyy",Now))
3. A 10 digit number, that is vital because it keeps track of
certain items
that never must be identical, and it cannot be a autonumber.

The number is therefor: 100020041234567890

So how can I combine these three and make sure I always update the
next record with 1? I think I saw an example from a book on access 97
once, but have forgotten where and why...

Hopefully Yours,

Me.Name
Nov 13 '05 #4
Wuld you ever need to query on any of the items -- like all of a certain
customer's records? It might be best to keep them in three separate fields
and then just concatenate them for display purposes. Its always easier to
visually combine then it is to try to split/parse later....
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies
Windows International Division

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Geir Baardsen" <ge***********@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
OK!
Give me a suggestion: the number I'll produce is being made of three
details:

1. The customer number (1000)
2. The actual year (DatePart("yyyy",Now))
3. A 10 digit number, that is vital because it keeps track of
certain items
that never must be identical, and it cannot be a autonumber.

The number is therefor: 100020041234567890

So how can I combine these three and make sure I always update the
next record with 1? I think I saw an example from a book on access 97
once, but have forgotten where and why...

Hopefully Yours,

Me.Name

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: toa | last post by:
Hi! I'm trying to send a http request from a Windows form to a third-party server. At the outset, I got an exception - error "407 proxy authentication required", which I suppose is a message...
11
by: Steve Jorgensen | last post by:
I'm working on an application in Access 2002, and every time I'm done making changes in the VBA project, the database is noticeably larger after compacting, even when code changes are small or even...
2
by: EricaLRivera | last post by:
Hi Y'all I was hoping someone out there might be able to help me. I have an access program that needs to change the data types programatically. I have tried to do an alter column to change the...
4
by: vickeybird | last post by:
Hi, Im trying to implement flexwiki, an ASP.net based open source wiki. I tried compliing and deploying the solution on my local machine and it seems to be working fine. However on remote...
45
by: alertjean | last post by:
Or may be I am stubborn or dumb ... of not putting in a * in the typecast. This is code I am worrying about long long b=1; int *address ; address=(int)&b; printf ("%x %x...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.