One other thought. You could also use the DMax function instead of using a
Recordset.
Forms!frmAdd!frmDatasetInformation.Form!Geo_ref_object_type_id.Value =
DMax("[geo_ref_object_type_id]", "tbldatasetinformation") + 1
HTH,
Toby
----- Original Message -----
From: "Toby Bierly" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, December 19, 2005 1:36 PM
Subject: Re: [AccessDevelopers] Increment a number by 1
> You have to specify which field (even though there is only one) in the
> recordset you want to add 1 to. You can't add 1 to a recordset object --
it
> is not a numeric value. You don't need the rst.MovLast command either --
> Select Max query only returns one record. Current record is automatically
> the first record. Try this:
>
> ********************************************************************
> Dim dbs, rst
> Set dbs = OpenDatabase("database.mdb")
>
> Set rst = dbs.OpenRecordset("select max(geo_ref_object_type_id) from
> tbldatasetinformation;")
>
> Forms!frmAdd!frmDatasetInformation.Form!Geo_ref_object_type_id.Value
> = rst!geo_ref_object_type_id + 1
> ********************************************************************
>
> Also, geo_ref_object_type_id may need to be defined in your table as a
> number field. Not sure if it would work if it was defined as a text
field.
>
> HopeThatHelps,
> Toby
>
>
> ----- Original Message -----
> From: "seworkuk" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Monday, December 19, 2005 8:30 AM
> Subject: [AccessDevelopers] Increment a number by 1
>
>
> > I have a table which already has an autonumber field, however I want
> > to be able to update another field by 1 every time a new record is
> > added. Users add new records via a form. I have tried the following
> > code in the OnCurrent event of the form:
> >
> > ********************************************************************
> > Dim dbs, rst
> > Set dbs = OpenDatabase("database.mdb")
> >
> > Set rst = dbs.OpenRecordset("select max(geo_ref_object_type_id) from
> > tbldatasetinformation;")
> >
> > rst.MoveLast
> >
> > Forms!frmAdd!frmDatasetInformation.Form!Geo_ref_object_type_id.Value
> > = rst + 1
> > ********************************************************************
> >
> > but I get a Type Mismatch error message. My brain has shrivelled to
> > the size of a pea today and I can't think what is wrong with this.
> > Is there an easier way to do it?
> >
> > Thanks
> > Sharon
> >
> >
> >
> >
> >
> >
> >
> > Please zip all files prior to uploading to Files section.
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > BEGIN-ANTISPAM-VOTING-LINKS
> > ------------------------------------------------------
> >
> > Teach CanIt if this mail (ID 27269287) is spam:
> > Spam:
> http://web2.cleanmessage.com/b.php?c=s&i=27269287&m=dd4c90796de6
> > Not spam:
> http://web2.cleanmessage.com/b.php?c=n&i=27269287&m=dd4c90796de6
> > Forget vote:
> http://web2.cleanmessage.com/b.php?c=f&i=27269287&m=dd4c90796de6
> > ------------------------------------------------------
> > END-ANTISPAM-VOTING-LINKS
> >
>
>
>
>
>
> Please zip all files prior to uploading to Files section.
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> --
> BEGIN-ANTISPAM-VOTING-LINKS
> ------------------------------------------------------
>
> Teach CanIt if this mail (ID 27283966) is spam:
> Spam:
http://web2.cleanmessage.com/b.php?c=s&i=27283966&m=6831442484f7
> Not spam:
http://web2.cleanmessage.com/b.php?c=n&i=27283966&m=6831442484f7
> Forget vote:
http://web2.cleanmessage.com/b.php?c=f&i=27283966&m=6831442484f7
> ------------------------------------------------------
> END-ANTISPAM-VOTING-LINKS
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
AIDS in India: A "lurking bomb." Click and help stop AIDS now.
http://us.click.yahoo.com/9QUssC/lzNLAA/TtwFAA/q7folB/TM
--------------------------------------------------------------------~->
Please zip all files prior to uploading to Files section.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AccessDevelopers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/