By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

Dim me as stubborn!

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.