View Single Post
  #6  
Old November 16th, 2009, 04:13 PM posted to microsoft.public.access.forms
Scott_Brasted via AccessMonster.com
external usenet poster
 
Posts: 49
Default Using a Combo Box to Find Records

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


BruceM wrote:
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
may work, too, but I tend to regard the Load event as the first opportunity
to work with data. If you are checking the value of a field, Open is too
soon.

I'm not sure why Jeanette suggested calling the combo box After Update code.
Perhaps there is something in the code at Allen Browne's web site of which
she has specific knowledge I am lacking, but in any case you need to compile
the code if you have not done so (Debug Compile).

You speak of adding a second line of code, but I don't see where Jeanette
suggested that, so it is not clear to me what you did. It would help if you
post the actual code, as well as the text of any error messages. There is no
way to know what you would regard as ominous.

Good morning Jeanette,

[quoted text clipped - 16 lines]
Thanks,
Scott


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