Connecting Tech Pros Worldwide Help | Site Map

Dim me as stubborn!

  #1  
Old November 13th, 2005, 02:55 AM
Geir Baardsen
Guest
 
Posts: 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?
  #2  
Old November 13th, 2005, 02:55 AM
ByteMyzer
Guest
 
Posts: n/a

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]


  #3  
Old November 13th, 2005, 02:55 AM
Randy Harris
Guest
 
Posts: n/a

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]


  #4  
Old November 13th, 2005, 02:55 AM
Geir Baardsen
Guest
 
Posts: n/a

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
  #5  
Old November 13th, 2005, 02:55 AM
Michael \(michka\) Kaplan [MS]
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP String Parsing Msaccess cephal0n answers 7 February 21st, 2008 07:45 PM
Membership History unionhorse answers 11 February 12th, 2008 04:54 PM
User selectable color spec in data fields on printed reports MLH answers 13 November 13th, 2005 04:05 PM
What do you think of resizing 1em to 10px? Michael Kalina answers 86 July 20th, 2005 11:57 PM