Highest Value Default

TheMonge

New Member
Joined
Jan 16, 2003
Messages
12
One more question! This database is killing me. I have made a form to update my job performed table. How can I make the job performed table automatically start the job number as the highest job # + 1, therefore creating a unique value for my table and then I can just type away.

Anthony
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
On 2003-01-20 23:27, TheMonge wrote:
One more question! This database is killing me. I have made a form to update my job performed table. How can I make the job performed table automatically start the job number as the highest job # + 1, therefore creating a unique value for my table and then I can just type away.

Anthony

Hi Anthony, I dont think this is that straight forward. You are effectively wanting a custom AutoNumber. An AutoNumber increments with each new record (after its saved) but if you created a new field with an AutoNum data type then this wouldnt tie in with your existing job numbers.

Perhaps the easiest way is to use an append query to add + 1 eg max([FieldName])+1. In addition you will have to create a button to add a new record, so when clicked it runs the append query then returns you to the newly created record.

All a bit messy really. I will be interested to see if someone else has a better idea.



_________________
cheers
Parry
This message was edited by parry on 2003-01-21 18:11
 
Upvote 0
You can put some code in the BeforeInsert event of the form. Something like this:<pre>Private Sub Form_BeforeInsert(Cancel As Integer)
txtJobNum = DMax("[JobNumber]", "MyTable") + 1
End Sub</pre>

Where

txtJobNum = the text box that holds your "job number" field
JobNumber = the name of your "job number" field
MyTable = the name of your table.

Hope this helps,

Russell

p.s. I'll bet Parry's interested... :wink:
This message was edited by Russell Hauf on 2003-01-21 18:21
 
Upvote 0
Thanks for the help guys! I am so glad I found this web-site, you guys are so helpful. I wish I would have studied more of the office package and less of the networking. This is the fun stuff!

Anthony
 
Upvote 0
On 2003-01-21 18:20, Russell Hauf wrote:
You can put some code in the BeforeInsert event of the form. Something like this:<pre>Private Sub Form_BeforeInsert(Cancel As Integer)
txtJobNum = DMax("[JobNumber]", "MyTable") + 1
End Sub</pre>

Where

txtJobNum = the text box that holds your "job number" field
JobNumber = the name of your "job number" field
MyTable = the name of your table.

Hope this helps,

Russell

p.s. I'll bet Parry's interested... :wink:
This message was edited by Russell Hauf on 2003-01-21 18:21

Superb, well done Russell! I was thinking of an event in the form but couldnt get it to work. At least I had the Max piece right :)
Although I must say you used an excessive amount of code - a whole one line. You'll have to try better next time :wink:

_________________
cheers
Parry
This message was edited by parry on 2003-01-22 00:59
 
Upvote 0

Forum statistics

Threads
1,221,507
Messages
6,160,219
Members
451,631
Latest member
coffiajoseph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top