[AccessD] Hi I am back and stuck

Steve Schapel miscellany at mvps.org
Sun Jun 17 00:41:11 CDT 2007


Joe,

Is the EmpRecNum field a number or text data type?

Either way, I don't understand the purpose of the Str() function being 
used in this context.

Also, I think it may be more suitable to test the NoMatch property of 
the recordset, rather than EOF?

FWIW, here's the type of syntax I would usually use for this type of 
operation:

  Private Sub Combo27_AfterUpdate()
     Dim rs As Recordset
     Set rs = Me.RecordsetClone
     rs.FindFirst "[EmpRecNum]=" Me.Combo27
     If rs.NoMatch Then
        MsgBox "No such record"
     Else
        Me.Bookmark = rs.Bookmark
     End If
     Set rs = Nothing
  End Sub

Regards
Steve


Joe Hecht wrote:
> Hi Gang,
> 
>  
> 
> I am back and feeling silly. Can not make combo box work.
> 
>  
> 
> I want to go to the record the combo selects
> 
>  
> 
>  
> 
>  
> 
> Private Sub Combo27_AfterUpdate()
> 
>     ' Find the record that matches the control.
> 
>     Dim rs As Object
> 
>  
> 
>     Set rs = Me.Recordset.Clone
> 
>     rs.FindFirst "[EmpRecNum] = " & Str(Nz(Me![Combo27], 0))
> 
>     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> 
> End Sub
> 
>  
> 
> The sql
> 
>  
> 
> SELECT tblEmployee.EmpRecNum, tblEmployee.EmpNumber, tblEmployee.EmpFname,
> tblEmployee.EmpLName, [emplname] & ", " & [empfname] & " " & [empNumber] AS
> Expr1
> 
> FROM tblEmployee
> 
> ORDER BY tblEmployee.EmpLName;
> 
>  
> 
> I have it so that it is showing expression one but I get 
> 
>  
> 
> Run time error 13 on the following code line:
> 
>  
> 
> rs.FindFirst "[EmpRecNum] = " & Str(Nz(Me![Combo27], 0))
> 
>  
> 
>  
> 
> Please advise
> 
>  
> 
> Thanks
> 
>  
> 
> Joe
> 



More information about the AccessD mailing list