Re: Using a Combo Box to Find Records

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Jeanette did not know the name of your combo box, so she used a generic name
NameOfCombo, and the instruction "Replace NameOfCombo of your combo". I will
admit this is a bit cryptic. The idea is that you would substitute the
actual name of your combo box:

Me.[cboMoveTo] = Me.[cboMoveTo].ItemData(0)

This should show you the first item on the list. Try placing the code in the
form's Load event. If this is not what you want, please specify what you do
want.

As for the compile error, I understand you to be saying this is the
troublesome line of code:

ExitLabel.FontUnderline = True

This underlines the font in ExitLabel, which is presumably a label, probably
next to the Exit button. If there is no such label (as I suspect), delete
the code or rename the label (if it is now named something else). It seems
the code in the Exit button's Got Focus event is looping through controls
named Option1, Option2, etc., and OptionLabel1, OptionLabel2, etc., making
Option1 etc. invisible, and changing the label font to normal weight. It
does this for the number of times represented by the variable conNumButtons,
which presumably is a constant somewhere in the code. You could delete the
entire Got Focus code and not do any harm I can see. All it does is some
formatting and stuff like that. Or comment it out by placing an apostrophe
in front of each line of code.

A compile error contains some sort of description. Like any error about
which you are seeking help, post the full message you receive. In this case
I think I can guess what is going on, but the less guessing responders have
to do the sooner you will receive a targeted response.

Scott_Brasted wrote:
Buce, thanks for the reply.

Here is the code for the cbo:

Private Sub CboMoveTo_AfterUpdate()
Dim rs As DAO.Recordset
If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[SetupID] = " & Me.cboMoveTo
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

As I said it works, as is but show a blank box when the form opens.

Jeanette's code: Me.[NameOfCombo] = Me.[NameOfCombo].ItemData(0)

Jeanette's second respone had the following comment:
Oops,
that extra line is wrong.
It should read
Call [NameOfCombo]_AfterUpdate

None of this does anything to the cbo.

When I try to compile, I get errow I cannot understand. The code the compiler
stosa at is MS code. It came with the db and is part of the switchboard. Here
is the code that contans the place wher the compiler stops:
Private Sub cmdExit_GotFocus()
Dim intOption As Integer

'If the Exit Button has received the focus, turn off the focus on all the
menu options
For intOption = 1 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Next intOption

ExitLabel.FontUnderline = True
End Sub

ExitLable is highlighted by the compiler.

Best,
Scott

The Current event will run every time you navigate to a record. That may not
be what you need. To set a value initially I would use the Load event. Open
[quoted text clipped - 17 lines]
Thanks,
Scott

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200911/1

.



Relevant Pages

  • Newbie asm question
    ... prog.asm:4: attempt to define a local label before any non-local label ... It won't compile with nasm or masm, ...
    (alt.lang.asm)
  • Trustix 2.1 - kernel 2.2.26 compilation error ?
    ... Can someone explain it to me, what's wrong when making new kernel. ... kernel-source-2.4.26-3tr compile good, as usual. ... label at end of compound statement ...
    (comp.os.linux.misc)
  • Re: COBOL compiler written in COBOL
    ... A label had to start with a numeric character and be up to 16 characters ... Because UT06 source could be entirely free-form to allow it to ... You could of course make it look like COBOL if you want. ... Then at end of compile, ...
    (comp.lang.cobol)
  • Re: Odd behavior with odd code
    ... A label is not an object, and cannot have its address taken. ... You didn't compile with C, you compiled with gcc. ... For assistance with the C-like language implemented ...
    (comp.lang.c)