Jurgen Welz
jwelz at hotmail.com
Sun Jul 12 11:57:09 CDT 2009
DAO? Make certain of your references. I believe every time you call RecordsetClone, you get a new clone so you'll need to use dimension a recordset variable and set it to the recordsetclone and use the variable. I'm not certain of this, but in any event, it's faster to reuse the variable. I see you have a dot betwen recordset and clone in the 2nd line of the code you posted. (Recordset.Clone rather than RecordsetClone). I'd check the data type of fldPOHIS is numeric. If it's string, you need: .FindFirst "fldPOHID = '" & Me.cboFindPO & "'". I'd also check that the lookup combo is bound to the first column by placing a break in the code and doing a debug.print me.cboFindPO.Column(0). That should tell you the datatype while you're at it. You'll need a NZ(me me.cboFindPO, -1). Users might delete the selection in the combo before they leave it and I like to use a guaranteed no record is found on a blank combo and -1 doesn't come up as an autonumber for about 4 billion records. One other thing I like to do is, if the form is designed to display one record at a time and isn't continuous or a datasheet view, I like to set the form recordset to a single record. That way the form loads very quickly and works similar to data on demand subforms. If you look online at: http://msdn.microsoft.com/en-us/library/bb258175.aspx you'll find the following example: Sub SupplierID_AfterUpdate() Dim rst As Recordset Dim strSearchName As String Set rst = Me.RecordsetClone strSearchName = Str(Me!SupplierID) rst.FindFirst "SupplierID = " & strSearchName If rst.NoMatch Then MsgBox "Record not found" Else Me.Bookmark = rst.Bookmark End If rst.Close End Sub The msdn example uses a numeric ID but does a string conversion as the findfirst method accepts a search parameter. Most people that I know just pass the numeric and allow the implicit type conversion resulting from the concatenation. I'm also not sure of the Str(Me!SupplierID). I'd have used strSearchName = cStr(me!SupplierID & "") which also handles the nulls. Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com > From: rockysmolin at bchacc.com > To: accessd at databaseadvisors.com > Date: Sun, 12 Jul 2009 06:47:30 -0700 > Subject: [AccessD] FindFirst Not Working > > Dear List: > > Legacy app. I added a form to make purchase orders. In the AfterUpdate > event of the combo box which finds an existing purchase order I added the > following: > > > Private Sub cboFindPO_AfterUpdate() > Me.Recordset.Clone.FindFirst "fldPOHID = " & Me.cboFindPO.Column(0) > MsgBox Me.RecordsetClone.NoMatch > Me.Bookmark = Me.RecordsetClone.Bookmark > Me.Refresh > End Sub > > But the form does not move to the selected Purchase Order. > > I put in the MsgBox just to make sure NoMatch was False. I added the > Refresh to see if that was the problem. > > Does anyone see a reason why this shouldn't work? > > MTIA, > > Rocky _________________________________________________________________ Internet explorer 8 lets you browse the web faster. http://go.microsoft.com/?linkid=9655582