Look up Text box Vs. Combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MNNovice
    Contributor
    • Aug 2008
    • 418

    Look up Text box Vs. Combo box

    Look up Text Box Vs Combo Box

    tblOrg has these fields
    OrgID PK
    OrgNo Text
    OrgDescr Text


    I would like to see the OrgNo get displayed in two other tables: tblExpense and tblRevenue from a drop down list on the forms that are based on these two tables, ie., tblExpese & tblRevenue

    To include OrgID as one of the fields in these two tables, I first selected the data type to be a Number. When I tried to enter data, I get the error message that reads:

    “The value you entered is not valid for this field. For example, you must have entered text in a numeric field…”

    Of course I did.

    What is the solution? Can somebody please help? Many thanks.
    Last edited by NeoPa; Apr 24 '09, 12:04 AM. Reason: OrdID -> OrgID
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    I'm sorry, but I've spent five minutes trying to understand your post. First you speak of wanting to include OrgNo in the other two tables, then you go on to talk about what you're doing to include OrgID in the tables.

    You have OrdID marked as "PK" indicating Primary Key, but you don't say what datatype it is.

    Clarification is needed here, but generally speaking, if you have a field in multiple tables, as PK and FKs, the datatypes have to be the same in each table. The only exception to this is if your PK is being generated by Access as an AutoNumber. In that case, the datatype for it in the tables where it will appear as a FK would have to be set to Number and Long.

    Linq ;0)>

    Comment

    • MNNovice
      Contributor
      • Aug 2008
      • 418

      #3
      missingling:

      My apologies for not being clear.

      OrgID is a PK and the data type is auto number

      Data type for OrgNo is text.

      Now if I want to see a drop down list of OrgNo in a form (let’s call it frmExpense) which is based on a table called tblExpense – what field I add to this table to tie the OrgNo from the tblOrg?

      Hope this makes it clear. If not, feel free to post your question.

      Thanks for spending 5 preciouis minutes of your time to decipher my questions.

      MNNovice

      Comment

      • DonRayner
        Recognized Expert Contributor
        • Sep 2008
        • 489

        #4
        For the rowsource property of the listbox you would set it to this. Include the quotes.
        Code:
        "SELECT tblOrg.* FROM tblOrg;"
        Set the listbox Bound Column Property to 1 (This would be the OrdID)
        Set the listbox Column Count Property to 2
        Set the listbox Column Widths Property to 0";1" (This will hide the OrdID column)

        There you have it. Your listbox will show the OrgNo text but what gets entered into the record will be the OrgID number.

        Hope this helps.
        Don

        Comment

        • MNNovice
          Contributor
          • Aug 2008
          • 418

          #5
          Don:

          Sorry to let you know it didn't work. I still got the same error message, "You may have entered text in a numeric field or a number that is larger than the field setting."

          OrgID is PK and has an auto number data type
          OrgNo has text data type with a field size of 20

          I am trying to enter 4XXXX as a value for the organization on the form.

          Any suggestions?

          Comment

          • DonRayner
            Recognized Expert Contributor
            • Sep 2008
            • 489

            #6
            What is the field size setting for the field in the table that the listbox is bound to.

            Comment

            • MNNovice
              Contributor
              • Aug 2008
              • 418

              #7
              Don:

              The problem is resolved now. I deleted the sub form and recreated the tblExpense and tblRevenue - that took care of it. Bizzare! Must be a Microsoft issue.

              I need help with something else. tblAccounts has these fields

              AccountID PK (Auto)
              AccountNo Text
              AccountDescr Text

              In my expense or revenue form that are based on tblExpense and tblRevnue I would like the AccountDescr field to be automatically filled in once the AccountID is entered. How to do this? Can you provide some guidance?

              Thanks.

              Comment

              • DonRayner
                Recognized Expert Contributor
                • Sep 2008
                • 489

                #8
                If your AccountID field on your form is a list or combo box you could do something like I outlined in post #4 except set the column count property to 3 instead of 2. and change tblOrg to tblAccounts

                Then in the after update event for the list/combo box you would put the following code.
                Code:
                Me.AccountDescr = me.AccountID.column(2)
                Just change the values in the listbox Column Widths Property to 0 if you don't want them visible to the user. So if you want the ID visible but not the others it could be 1";0";0" or such.

                Please note that when referring to the data contained in the list/combo box the columns are counted as 0,1,2 But when referring to the column that is "Bound" to the table they are counted as 1,2,3.

                If you're not using a list/combo box we will have to ask one the the moderators to break this off into a new thread as it would become confusing to others searching the site for answers.

                Comment

                • MNNovice
                  Contributor
                  • Aug 2008
                  • 418

                  #9
                  Don:

                  Beleive it or not, this morning that form went back to its bizzare mode meaning each time I tried to pull a AcctNo (a text field), I got the same error message. Well, I deleted the table (tblExpense and tblRevenue) and this time created new ones from the scratch. Everything seems to be working now. Hopefully I will not have to repeat this process in future.

                  Many thanks for your help with the auto fill part. I appreciate. I am going to close this thread and shall post new questions on new threads. Thanks again.

                  Comment

                  • DonRayner
                    Recognized Expert Contributor
                    • Sep 2008
                    • 489

                    #10
                    Glad I could help, good luck with your project.

                    Comment

                    Working...