Next Hireno

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goldstar
    New Member
    • Jan 2008
    • 49

    Next Hireno

    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
    Code:
    Set rsitem = currentDatabase.OpenRecordset("tblhire")
    rsitem.MoveLast
    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
    Last edited by Stewart Ross; Mar 14 '08, 04:49 PM. Reason: code tags corrected
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

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

    -Stewart

    Comment

    • goldstar
      New Member
      • Jan 2008
      • 49

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

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        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

        Comment

        • goldstar
          New Member
          • Jan 2008
          • 49

          #5
          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.ht ml

          Thanks

          Comment

          Working...