Connecting Tech Pros Worldwide Forums | Help | Site Map

Next Hireno

Member
 
Join Date: Jan 2008
Posts: 49
#1: Mar 14 '08
Just a quick query, currently i have an hire form, when the form is opened the next hireno would automatically be displayed within this box. This works fine if i already have an order stored. But if i was to clear the hire table, so no hires are currently saved, i would like 1 to be displayed within the textbox when opened. but a message appears saying, no current record.

This is what i am using
Expand|Select|Wrap|Line Numbers
  1. Set rsitem = currentDatabase.OpenRecordset("tblhire")
  2. rsitem.MoveLast
  3. txthireno.Value = rstitem("hireno") + 1
The hire no in the table is a composite key with clientID. Is there a way in which it can automatically bring up 1 in the hire form when opened when it is part of a composite key? Hireno is currently autonumber

Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#2: Mar 14 '08

re: Next Hireno


Hi. Why not just set the Default Value property of the textbox in your form to 1?

-Stewart
Member
 
Join Date: Jan 2008
Posts: 49
#3: Mar 14 '08

re: Next Hireno


It still brings up an error, i think because it is a composite key, it requires something to be in both the fields
Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#4: Mar 14 '08

re: Next Hireno


Quote:

Originally Posted by goldstar

It still brings up an error, i think because it is a composite key, it requires something to be in both the fields

Hi Goldstar. It wasn't until I read your other recent thread at http://www.thescripts.com/forum/thread780473.html that I realised you are not using standard methods of database design, and in particular you are trying to place multiple values into individual controls, for reasons that I can only guess at.

If there is a compound key involved you should as far as possible have the field values automated by an appropriate method (such as linking parent-child fields between a subform and a main form). It is never appropriate to have users enter compound key values themselves in a single text box.

There are useful examples of typical form/subform designs in the Northwind database that comes with Access. You will not find any that require users to enter compound key values in single textbox controls.

This is a different matter from displaying a compound key value (for example a year followed by a job number, 2008-105 say) where you can have a single text box displaying the value without expecting users to enter it that way.

-Stewart
Member
 
Join Date: Jan 2008
Posts: 49
#5: Mar 14 '08

re: Next Hireno


Thank you stewart the information provided is really useful.

By the way would you have a solution to my other query which was posted, http://www.thescripts.com/forum/thread780473.html

Thanks
Reply