Form Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • j0rdanf1
    New Member
    • Oct 2006
    • 35

    Form Help

    Hello,

    Is it possible to have a form label which can input new information as well as find exisiting information.

    e.g

    user id - if not found add to database?

    cheers
  • VALIS
    New Member
    • Oct 2006
    • 21

    #2
    Originally posted by j0rdanf1
    Hello,

    Is it possible to have a form label which can input new information as well as find exisiting information.

    e.g

    user id - if not found add to database?

    cheers
    j0rdanf1,
    Yes it is.

    How are you searching for the user id? Are you using a combo box?
    If so you could use the "On Not In List" event to update your listbox.
    This will update the underlying table being used as the recordsource.
    There's an example in the Access Help files for the NotInList Event.
    Or you could send more detail?

    Regards,
    VALIS

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32634

      #3
      It's good to see more new members coming up with very clear answers to questions.
      Ups to you for that Valis.

      Comment

      • j0rdanf1
        New Member
        • Oct 2006
        • 35

        #4
        This is going to be hard to explain but i will give it a bash,

        I have a label where you input a new user id, this then gets saved to a table called user (user id being the primary key)

        the table looks like this

        user id:
        first name:
        last name:
        start date:
        transfer:
        leave date:

        however if i input this information directly into the table and then go into the form and type the user id in, it does not find the user, it then comes up with an error that i cant have a duplicate record. hence why i wish to know if it can do a look up before creating a new record

        Comment

        • VALIS
          New Member
          • Oct 2006
          • 21

          #5
          Originally posted by j0rdanf1
          This is going to be hard to explain but i will give it a bash,

          I have a label where you input a new user id, this then gets saved to a table called user (user id being the primary key)

          the table looks like this

          user id:
          first name:
          last name:
          start date:
          transfer:
          leave date:

          however if i input this information directly into the table and then go into the form and type the user id in, it does not find the user, it then comes up with an error that i cant have a duplicate record. hence why i wish to know if it can do a look up before creating a new record
          Do you save the table and refresh the query before searching for this new record? If the form or underlying query behind the control isn't refreshed access won't register the new entry.

          Comment

          • j0rdanf1
            New Member
            • Oct 2006
            • 35

            #6
            Originally posted by VALIS
            Do you save the table and refresh the query before searching for this new record? If the form or underlying query behind the control isn't refreshed access won't register the new entry.

            Yes i do, thats what im confused about, it shows up in the table but will not in the form.

            Comment

            • VALIS
              New Member
              • Oct 2006
              • 21

              #7
              Originally posted by j0rdanf1
              Yes i do, thats what im confused about, it shows up in the table but will not in the form.
              Is there any coding associated with your form? ( I assume there is since you mention you're using a LABEL to input ) If your code deals with searching for the typed entry in the table it might need a requery statement.

              Comment

              • j0rdanf1
                New Member
                • Oct 2006
                • 35

                #8
                Requery? would this be done on a after-update?

                Comment

                • j0rdanf1
                  New Member
                  • Oct 2006
                  • 35

                  #9
                  Originally posted by j0rdanf1
                  Requery? would this be done on a after-update?
                  Just a quick update,

                  Had a look on the internet for a possible solution but it returns an invalid syntax

                  =DLookup("[First Name]", "[USER]", "[User ID]=" & txtUser ID)

                  Comment

                  • MMcCarthy
                    Recognized Expert MVP
                    • Aug 2006
                    • 14387

                    #10
                    Originally posted by j0rdanf1
                    Just a quick update,

                    Had a look on the internet for a possible solution but it returns an invalid syntax

                    =DLookup("[First Name]", "[USER]", "[User ID]=" & txtUser ID)

                    "txtUser ID"

                    You can't use a name that has a space in it without enclosing in square brackets.

                    Try this:

                    =DLookup("[First Name]", "[USER]", "[User ID]=" & [txtUser ID])

                    Comment

                    Working...