Connecting Tech Pros Worldwide Help | Site Map

Dim me as stubborn!

Geir Baardsen
Guest
 
Posts: n/a
#1: Nov 13 '05
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?
ByteMyzer
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Dim me as stubborn!


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" <geir_baardsen@hotmail.com> wrote in message
news:35f9d8b7.0408210708.19b757de@posting.google.c om...[color=blue]
> 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?[/color]


Randy Harris
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Dim me as stubborn!


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" <sbc@nospam.news.chi.sbcglobal.net> wrote in message
news:AqKVc.6173$FV3.3638@newssvr17.news.prodigy.co m...[color=blue]
> 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" <geir_baardsen@hotmail.com> wrote in message
> news:35f9d8b7.0408210708.19b757de@posting.google.c om...[color=green]
> > 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?[/color]
>
>[/color]


Geir Baardsen
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Dim me as stubborn!


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
Michael \(michka\) Kaplan [MS]
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Dim me as stubborn!


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" <geir_baardsen@hotmail.com> wrote in message
news:35f9d8b7.0408211940.436da3de@posting.google.c om...[color=blue]
> 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[/color]


Closed Thread