Autonumber problems

jds

Registered User.
Local time
Today, 22:30
Joined
May 23, 2000
Messages
18
OK here it is as plain as I can put it without confusing myself. I am trying to get to forms to link together and use the same run of Autonumber between the 2 of them. (i.e. open first form and # would be 1...when I open the second form the number should start at 2) I have muddled my way through most of this without getting too much help, but this has got me stumped.

Also on the same note, is it possible to have a "Set button" for the autonumber. What I mean is can I have a button that won't allow the number to appear until I choose it? If not thats OK.

Any help would be greatly appreciated.

Thanx
JDS
 
Hello,

(I am not sure if I understand your problem)

If the forms are based on the same table, it should automatically generate a next number. If you open form1 and it shows a 1, then the 1 is stored in the table. If you open form 2 then autonumber generates a 2.

If they are not based on the same table. (Only form 1 is based on the table with autonumber kolom) then you should write some code to find the highest number of the table and generates a nummer one higher. ('On open' event of the second form.)

For further help: I keep an eye on this post.

Greetings,

Albert
 
Thanx for your timely reply

Yes it is 2 seperate tables. Now not to sound like a pest, but could you give me some example coding that I should enter for an onopen expression? You could post here or email me at fireman_gcfd@yahoo.com

Thanx again

JDS
 
Hello,

I post the anwer here, so someone can correct me if I'am sending you in the wrong direction.

Your demands: If form 1 has a record with number 1 then you don't want form 2 to have a record with number 1, but with number 2. And so on.(For clearity)

The first table must be autonumbering. The second not! The second must be numeric. (The number kolom)

After the 'On open' propertie of the second form, type the following:

Dim db as dabatase
dim rc as recordset

set db = currentdb()
set rc = db.openrecordset("SELECT number from [tblnaam] ORDER BY number")'tblname is the name of the autonumber table. Use the brackets. number is the name of the colom.

rc.movelast 'Gives an error if there ar no records! Moves to the last and highest record.

textbox_on_second_form.text = rc("number") + 1 'number in the rc("number") is the name of the autonumber kolom in the first table. ('Autonumber table')

'I am not sure of the 'textbox_on_second_form.text. If access complains about the foces try using:

- textbox_on_second_form
OR
- 'textbox_on_second_form.setfocus
textbox_on_second_form.text = .......

NOTE: the datatype of the second form (table) should not be autonumber!

If you need more help, just post.

Greetings,

Albert
 
Thanx for all your replies

I guess I should have mentioned what these forms were for. I am building a Fire Dispatch report form. The reason I have 2 seperate forms is because we have 2 seperate Fire Stations that we need to track by Incident number. I will try all the suggetions that have been given to me and I will let you know how I make out with them.

Thnx
JDS
 

Users who are viewing this thread

Back
Top Bottom