Enter value into combo box with code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ShyGuy

    Enter value into combo box with code?

    I have a form with a combo box for last name. It shows the record
    with whatever name I select in the combo box. I am trying to get the
    same results with code when I open the form by using a value from
    another form.

    I tried

    Me.RecordsetClo ne.FindFirst "[LastName] = '" &
    Forms!SelectNam e![snLastName] & "'"
    Me.Bookmark = Me.RecordsetClo ne.Bookmark

    Am I just missing something small or is this not possible?

    Thanks for any help.
  • Rog

    #2
    Re: Enter value into combo box with code?

    You don't need the single quotes here.
    Try: Me.RecordsetClo ne.FindFirst "[LastName] = " &
    Forms!SelectNam e![snLastName]

    Comment

    • ShyGuy

      #3
      Re: Enter value into combo box with code?

      On 11 Jan 2005 00:29:50 -0800, "Rog" <delahayerc@sta te.gov> wrote:
      [color=blue]
      >Me.RecordsetCl one.FindFirst "[LastName] = " &
      >Forms!SelectNa me![snLastName][/color]


      Thanks for the FAST reply. I tried this and received the following
      error message.

      Run-time error '438':

      Object doesn't support this property or method

      I copied and pasted the code you sent so I'm stumped. ;-(

      Comment

      • Bilk Whitey

        #4
        Re: Enter value into combo box with code?

        ShyGuy <shyguy@shytown .com> wrote:
        [color=blue]
        > I tried this and received the following
        > error message.
        >
        > Run-time error '438':
        >
        > Object doesn't support this property or method[/color]

        What library references do you have set? If you haven't already, try
        selecting DAO version 3.6 (from Tools/References in a module window).

        Regards,
        Keith.

        Comment

        • hwangtw

          #5
          Re: Enter value into combo box with code?

          try:
          Me.RecordsetClo ne.FindFirst "[LastName] = '" &
          Forms!SelectNam e![snLastName].Text & "'"
          If Not Me.RecordsetClo ne.NoMatch Then
          Me.Bookmark = Me.RecordsetClo ne.Bookmark
          End If
          "ShyGuy" <shyguy@shytown .com> ¦b¶l¥ó
          news:9m17u09m9b rcfkbn22voa5u09 k9adhdb3h@4ax.c om ¤¤¼¶¼g...[color=blue]
          > I have a form with a combo box for last name. It shows the record
          > with whatever name I select in the combo box. I am trying to get the
          > same results with code when I open the form by using a value from
          > another form.
          >
          > I tried
          >
          > Me.RecordsetClo ne.FindFirst "[LastName] = '" &
          > Forms!SelectNam e![snLastName] & "'"
          > Me.Bookmark = Me.RecordsetClo ne.Bookmark
          >
          > Am I just missing something small or is this not possible?
          >
          > Thanks for any help.[/color]


          Comment

          • ShyGuy

            #6
            Re: Enter value into combo box with code?

            On 11 Jan 2005 10:19:47 GMT, Bilk Whitey
            <keith.wilby@Aw ayWithYerCrap.c om> wrote:
            [color=blue]
            >ShyGuy <shyguy@shytown .com> wrote:
            >[color=green]
            >> I tried this and received the following
            >> error message.
            >>
            >> Run-time error '438':
            >>
            >> Object doesn't support this property or method[/color]
            >
            >What library references do you have set? If you haven't already, try
            >selecting DAO version 3.6 (from Tools/References in a module window).
            >
            >Regards,
            >Keith.
            >www.keithwilby.com[/color]

            DAO version 3.6 is checked..

            Comment

            • ShyGuy

              #7
              Re: Enter value into combo box with code?

              This didn't work either. With the "Text" after [snLastName] I got the
              following..

              You can't reference a property or method for a control unless the
              control has the focus.

              Without the "Text" I don't get the error but nothing happens. The
              form opens to the first record. I even tried puttin the code in a
              command button. Nothing. ;-(



              On Tue, 11 Jan 2005 22:45:59 +0800, "hwangtw" <hwangtw@seed.n et.tw>
              wrote:
              [color=blue]
              >try:
              >Me.RecordsetCl one.FindFirst "[LastName] = '" &
              >Forms!SelectNa me![snLastName].Text & "'"
              >If Not Me.RecordsetClo ne.NoMatch Then
              > Me.Bookmark = Me.RecordsetClo ne.Bookmark
              >End If
              >"ShyGuy" <shyguy@shytown .com> ¦b¶l¥ó
              >news:9m17u09m9 brcfkbn22voa5u0 9k9adhdb3h@4ax. com ¤¤¼¶¼g...[color=green]
              >> I have a form with a combo box for last name. It shows the record
              >> with whatever name I select in the combo box. I am trying to get the
              >> same results with code when I open the form by using a value from
              >> another form.
              >>
              >> I tried
              >>
              >> Me.RecordsetClo ne.FindFirst "[LastName] = '" &
              >> Forms!SelectNam e![snLastName] & "'"
              >> Me.Bookmark = Me.RecordsetClo ne.Bookmark
              >>
              >> Am I just missing something small or is this not possible?
              >>
              >> Thanks for any help.[/color]
              >[/color]

              Comment

              • ShyGuy

                #8
                Re: Enter value into combo box with code? VERY STRANGE

                I just checked a bit deeper and found that the displayed record was
                still the first record but in the "Navigation Button" area the record
                number was the correct number for the record that should be displayed.
                I tried a requery before the Me.recordsetClo ne" code and it is now
                working.

                Thank you all for your help!! ;-)


                On Tue, 11 Jan 2005 03:03:18 -0500, ShyGuy <shyguy@shytown .com> wrote:
                [color=blue]
                >I have a form with a combo box for last name. It shows the record
                >with whatever name I select in the combo box. I am trying to get the
                >same results with code when I open the form by using a value from
                >another form.
                >
                >I tried
                >
                > Me.RecordsetClo ne.FindFirst "[LastName] = '" &
                >Forms!SelectNa me![snLastName] & "'"
                > Me.Bookmark = Me.RecordsetClo ne.Bookmark
                >
                >Am I just missing something small or is this not possible?
                >
                >Thanks for any help.[/color]

                Comment

                Working...